module Plutarch.Pair (PPair (..)) where

import GHC.Generics (Generic)
import Plutarch.Internal.Eq (PEq)
import Plutarch.Internal.PlutusType (DPTStrat, DerivePlutusType, PlutusType)
import Plutarch.Internal.ScottEncoding (PlutusTypeScott)
import Plutarch.Internal.Show (PShow)
import Plutarch.Internal.Term (PType, S, Term)

{- |
  Plutus encoding of Pairs.

  Note: This is represented differently than 'BuiltinPair'. It is scott-encoded.
-}
data PPair (a :: PType) (b :: PType) (s :: S)
  = PPair (Term s a) (Term s b)
  deriving stock ((forall x. PPair a b s -> Rep (PPair a b s) x)
-> (forall x. Rep (PPair a b s) x -> PPair a b s)
-> Generic (PPair a b s)
forall x. Rep (PPair a b s) x -> PPair a b s
forall x. PPair a b s -> Rep (PPair a b s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (a :: PType) (b :: PType) (s :: S) x.
Rep (PPair a b s) x -> PPair a b s
forall (a :: PType) (b :: PType) (s :: S) x.
PPair a b s -> Rep (PPair a b s) x
$cfrom :: forall (a :: PType) (b :: PType) (s :: S) x.
PPair a b s -> Rep (PPair a b s) x
from :: forall x. PPair a b s -> Rep (PPair a b s) x
$cto :: forall (a :: PType) (b :: PType) (s :: S) x.
Rep (PPair a b s) x -> PPair a b s
to :: forall x. Rep (PPair a b s) x -> PPair a b s
Generic)
  deriving anyclass ((forall (s :: S). PPair a b s -> Term s (PInner (PPair a b)))
-> (forall (s :: S) (b :: PType).
    Term s (PInner (PPair a b))
    -> (PPair a b s -> Term s b) -> Term s b)
-> PlutusType (PPair a b)
forall (s :: S). PPair a b s -> Term s (PInner (PPair a b))
forall (s :: S) (b :: PType).
Term s (PInner (PPair a b))
-> (PPair a b s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
forall (a :: PType) (b :: PType) (s :: S).
PPair a b s -> Term s (PInner (PPair a b))
forall (a :: PType) (b :: PType) (s :: S) (b :: PType).
Term s (PInner (PPair a b))
-> (PPair a b s -> Term s b) -> Term s b
$cpcon' :: forall (a :: PType) (b :: PType) (s :: S).
PPair a b s -> Term s (PInner (PPair a b))
pcon' :: forall (s :: S). PPair a b s -> Term s (PInner (PPair a b))
$cpmatch' :: forall (a :: PType) (b :: PType) (s :: S) (b :: PType).
Term s (PInner (PPair a b))
-> (PPair a b s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner (PPair a b))
-> (PPair a b s -> Term s b) -> Term s b
PlutusType, (forall (s :: S).
 Term s (PPair a b) -> Term s (PPair a b) -> Term s PBool)
-> PEq (PPair a b)
forall (s :: S).
Term s (PPair a b) -> Term s (PPair a b) -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
forall (a :: PType) (b :: PType) (s :: S).
(PEq a, PEq b) =>
Term s (PPair a b) -> Term s (PPair a b) -> Term s PBool
$c#== :: forall (a :: PType) (b :: PType) (s :: S).
(PEq a, PEq b) =>
Term s (PPair a b) -> Term s (PPair a b) -> Term s PBool
#== :: forall (s :: S).
Term s (PPair a b) -> Term s (PPair a b) -> Term s PBool
PEq, (forall (s :: S). Bool -> Term s (PPair a b) -> Term s PString)
-> PShow (PPair a b)
forall (s :: S). Bool -> Term s (PPair a b) -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
forall (a :: PType) (b :: PType) (s :: S).
(PShow a, PShow b) =>
Bool -> Term s (PPair a b) -> Term s PString
$cpshow' :: forall (a :: PType) (b :: PType) (s :: S).
(PShow a, PShow b) =>
Bool -> Term s (PPair a b) -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s (PPair a b) -> Term s PString
PShow)

instance DerivePlutusType (PPair a b) where type DPTStrat _ = PlutusTypeScott