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

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

{- |
  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 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
$cto :: forall (a :: PType) (b :: PType) (s :: S) x.
Rep (PPair a b s) x -> PPair a b s
$cfrom :: forall (a :: PType) (b :: PType) (s :: S) x.
PPair a b s -> Rep (PPair a b s) x
Generic)
  deriving anyclass (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
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner (PPair a b))
-> (PPair a b s -> Term s b) -> Term s 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
pcon' :: forall (s :: S). PPair a b s -> Term s (PInner (PPair a b))
$cpcon' :: forall (a :: PType) (b :: PType) (s :: S).
PPair a b s -> Term s (PInner (PPair a b))
PlutusType, 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
#== :: forall (s :: S).
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
PEq, 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
pshow' :: forall (s :: S). 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)

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