{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# OPTIONS_GHC -Wno-orphans #-}

{- | This module is designed to be imported qualified, as many of its
identifiers clash with the Plutarch prelude.
-}
module Plutarch.LedgerApi.AssocMap (
  -- * Types
  PMap (..),
  KeyGuarantees (..),
  Commutativity (..),

  -- * Functions

  -- ** Creation
  pempty,
  psingleton,
  psingletonData,
  punsortedMapFromFoldable,
  psortedMapFromFoldable,

  -- ** Transformation
  passertSorted,
  pforgetSorted,
  pmap,
  pmapData,
  pmapWithKey,
  pmapMaybe,
  pmapMaybeData,

  -- ** Relational lift
  pcheckBinRel,

  -- ** Comparison
  pkeysEqual,
  pkeysEqualUnsorted,

  -- ** Fold
  pall,
  pany,
  pfoldMapWithKey,
  pfoldlWithKey,

  -- ** Combination
  punionResolvingCollisionsWith,
  punionResolvingCollisionsWithData,
  pleftBiasedUnion,
  pdifference,
  pzipWithDefaults,
  pintersectionWith,
  pintersectionWithData,

  -- ** Query
  pnull,
  plookup,
  plookupData,
  plookupDataWith,
  pfindWithDefault,
  pfoldAt,
  pfoldAtData,
  ptryLookup,

  -- ** Modification
  pinsert,
  pdelete,
  pupdate,
  padjust,

  -- ** Key-value pair manipulation
  pkvPairKey,
  pkvPairValue,
  pkvPairLt,

  -- ** Conversion
  pkeys,
) where

import Data.Bifunctor (bimap)
import Data.Foldable (foldl')
import Data.Kind (Type)
import Data.Proxy (Proxy (Proxy))
import Data.Traversable (forM)
import GHC.Generics (Generic)
import Plutarch.Internal.Term (punsafeBuiltin)
import Plutarch.Internal.Witness (witness)
import Plutarch.LedgerApi.Utils (
  Mret,
  PSBool (PSFalse, PSTrue),
  psfalse,
  pstrue,
 )
import Plutarch.Prelude hiding (pall, pany, pmap, pnull, psingleton, pzipWith)
import Plutarch.Prelude qualified as PPrelude
import Plutarch.Unsafe (punsafeCoerce, punsafeDowncast)
import PlutusCore qualified as PLC
import PlutusLedgerApi.V3 qualified as Plutus
import PlutusTx.AssocMap qualified as PlutusMap
import Prelude hiding (pred)

-- TODO: Rename this, because this is actually a _sorting_ guarantee!

-- | @since 2.0.0
data KeyGuarantees = Sorted | Unsorted

-- | @since 2.0.0
newtype PMap (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type) (s :: S)
  = PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PMap keysort k v s -> Rep (PMap keysort k v s) x)
-> (forall x. Rep (PMap keysort k v s) x -> PMap keysort k v s)
-> Generic (PMap keysort k v s)
forall x. Rep (PMap keysort k v s) x -> PMap keysort k v s
forall x. PMap keysort k v s -> Rep (PMap keysort k v s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) x.
Rep (PMap keysort k v s) x -> PMap keysort k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) x.
PMap keysort k v s -> Rep (PMap keysort k v s) x
$cfrom :: forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) x.
PMap keysort k v s -> Rep (PMap keysort k v s) x
from :: forall x. PMap keysort k v s -> Rep (PMap keysort k v s) x
$cto :: forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) x.
Rep (PMap keysort k v s) x -> PMap keysort k v s
to :: forall x. Rep (PMap keysort k v s) x -> PMap keysort k v s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S).
 PMap keysort k v s -> Term s (PInner (PMap keysort k v)))
-> (forall (s :: S) (b :: S -> Type).
    Term s (PInner (PMap keysort k v))
    -> (PMap keysort k v s -> Term s b) -> Term s b)
-> PlutusType (PMap keysort k v)
forall (s :: S).
PMap keysort k v s -> Term s (PInner (PMap keysort k v))
forall (s :: S) (b :: S -> Type).
Term s (PInner (PMap keysort k v))
-> (PMap keysort k v s -> Term s b) -> Term s b
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
PMap keysort k v s -> Term s (PInner (PMap keysort k v))
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) (b :: S -> Type).
Term s (PInner (PMap keysort k v))
-> (PMap keysort k v s -> Term s b) -> Term s b
forall (a :: S -> Type).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: S -> Type).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
PMap keysort k v s -> Term s (PInner (PMap keysort k v))
pcon' :: forall (s :: S).
PMap keysort k v s -> Term s (PInner (PMap keysort k v))
$cpmatch' :: forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S) (b :: S -> Type).
Term s (PInner (PMap keysort k v))
-> (PMap keysort k v s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: S -> Type).
Term s (PInner (PMap keysort k v))
-> (PMap keysort k v s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S).
 Bool -> Term s (PMap keysort k v) -> Term s PString)
-> PShow (PMap keysort k v)
forall (s :: S).
Bool -> Term s (PMap keysort k v) -> Term s PString
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
(PIsData k, PIsData v, PShow k, PShow v) =>
Bool -> Term s (PMap keysort k v) -> Term s PString
forall (t :: S -> Type).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
(PIsData k, PIsData v, PShow k, PShow v) =>
Bool -> Term s (PMap keysort k v) -> Term s PString
pshow' :: forall (s :: S).
Bool -> Term s (PMap keysort k v) -> Term s PString
PShow
    )

-- | @since 2.0.0
instance DerivePlutusType (PMap keysort k v) where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
instance
  ( Plutus.ToData (AsHaskell k)
  , Plutus.ToData (AsHaskell v)
  , Plutus.FromData (AsHaskell k)
  , Plutus.FromData (AsHaskell v)
  ) =>
  PLiftable (PMap 'Unsorted k v)
  where
  type AsHaskell (PMap 'Unsorted k v) = PlutusMap.Map (AsHaskell k) (AsHaskell v)
  type PlutusRepr (PMap 'Unsorted k v) = [(Plutus.Data, Plutus.Data)]

  {-# INLINEABLE toPlutarchRepr #-}
  toPlutarchRepr :: AsHaskell (PMap 'Unsorted k v) -> PlutusRepr (PMap 'Unsorted k v)
toPlutarchRepr = ((AsHaskell k, AsHaskell v) -> (Data, Data))
-> [(AsHaskell k, AsHaskell v)] -> [(Data, Data)]
forall a b. (a -> b) -> [a] -> [b]
map ((AsHaskell k -> Data)
-> (AsHaskell v -> Data)
-> (AsHaskell k, AsHaskell v)
-> (Data, Data)
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: Type -> Type -> Type) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap AsHaskell k -> Data
forall a. ToData a => a -> Data
Plutus.toData AsHaskell v -> Data
forall a. ToData a => a -> Data
Plutus.toData) ([(AsHaskell k, AsHaskell v)] -> [(Data, Data)])
-> (Map (AsHaskell k) (AsHaskell v)
    -> [(AsHaskell k, AsHaskell v)])
-> Map (AsHaskell k) (AsHaskell v)
-> [(Data, Data)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map (AsHaskell k) (AsHaskell v) -> [(AsHaskell k, AsHaskell v)]
forall k v. Map k v -> [(k, v)]
PlutusMap.toList

  {-# INLINEABLE toPlutarch #-}
  toPlutarch :: forall (s :: S).
AsHaskell (PMap 'Unsorted k v) -> PLifted s (PMap 'Unsorted k v)
toPlutarch = AsHaskell (PMap 'Unsorted k v) -> PLifted s (PMap 'Unsorted k v)
forall (a :: S -> Type) (s :: S).
(PLiftable a, Includes DefaultUni (PlutusRepr a)) =>
AsHaskell a -> PLifted s a
toPlutarchUni

  {-# INLINEABLE fromPlutarchRepr #-}
  fromPlutarchRepr :: PlutusRepr (PMap 'Unsorted k v)
-> Maybe (AsHaskell (PMap 'Unsorted k v))
fromPlutarchRepr PlutusRepr (PMap 'Unsorted k v)
lst = ([(AsHaskell k, AsHaskell v)] -> AsHaskell (PMap 'Unsorted k v))
-> Maybe [(AsHaskell k, AsHaskell v)]
-> Maybe (AsHaskell (PMap 'Unsorted k v))
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap [(AsHaskell k, AsHaskell v)] -> AsHaskell (PMap 'Unsorted k v)
[(AsHaskell k, AsHaskell v)] -> Map (AsHaskell k) (AsHaskell v)
forall k v. [(k, v)] -> Map k v
PlutusMap.unsafeFromList (Maybe [(AsHaskell k, AsHaskell v)]
 -> Maybe (AsHaskell (PMap 'Unsorted k v)))
-> Maybe [(AsHaskell k, AsHaskell v)]
-> Maybe (AsHaskell (PMap 'Unsorted k v))
forall a b. (a -> b) -> a -> b
$ [(Data, Data)]
-> ((Data, Data) -> Maybe (AsHaskell k, AsHaskell v))
-> Maybe [(AsHaskell k, AsHaskell v)]
forall (t :: Type -> Type) (m :: Type -> Type) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [(Data, Data)]
PlutusRepr (PMap 'Unsorted k v)
lst (((Data, Data) -> Maybe (AsHaskell k, AsHaskell v))
 -> Maybe [(AsHaskell k, AsHaskell v)])
-> ((Data, Data) -> Maybe (AsHaskell k, AsHaskell v))
-> Maybe [(AsHaskell k, AsHaskell v)]
forall a b. (a -> b) -> a -> b
$ \(Data
kd, Data
vd) -> do
    AsHaskell k
k <- Data -> Maybe (AsHaskell k)
forall a. FromData a => Data -> Maybe a
Plutus.fromData Data
kd
    AsHaskell v
v <- Data -> Maybe (AsHaskell v)
forall a. FromData a => Data -> Maybe a
Plutus.fromData Data
vd
    (AsHaskell k, AsHaskell v) -> Maybe (AsHaskell k, AsHaskell v)
forall a. a -> Maybe a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (AsHaskell k
k, AsHaskell v
v)

  {-# INLINEABLE fromPlutarch #-}
  fromPlutarch :: (forall (s :: S). PLifted s (PMap 'Unsorted k v))
-> Either LiftError (AsHaskell (PMap 'Unsorted k v))
fromPlutarch = (forall (s :: S). PLifted s (PMap 'Unsorted k v))
-> Either LiftError (AsHaskell (PMap 'Unsorted k v))
forall (a :: S -> Type).
(PLiftable a, Includes DefaultUni (PlutusRepr a)) =>
(forall (s :: S). PLifted s a) -> Either LiftError (AsHaskell a)
fromPlutarchUni

-- | @since 2.0.0
instance PIsData (PMap keysort k v) where
  pfromDataImpl :: forall (s :: S).
Term s (PAsData (PMap keysort k v)) -> Term s (PMap keysort k v)
pfromDataImpl Term s (PAsData (PMap keysort k v))
x = Term s (PBuiltinList (PBuiltinPair PData PData))
-> Term s (PMap keysort k v)
forall (b :: S -> Type) (a :: S -> Type) (s :: S).
Term s a -> Term s b
punsafeCoerce (Term s (PBuiltinList (PBuiltinPair PData PData))
 -> Term s (PMap keysort k v))
-> Term s (PBuiltinList (PBuiltinPair PData PData))
-> Term s (PMap keysort k v)
forall a b. (a -> b) -> a -> b
$ Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
forall (s :: S).
Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
pasMap Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
-> Term s PData -> Term s (PBuiltinList (PBuiltinPair PData PData))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData (PMap keysort k v)) -> Term s PData
forall (s :: S) (a :: S -> Type).
Term s (PAsData a) -> Term s PData
pforgetData Term s (PAsData (PMap keysort k v))
x
  pdataImpl :: forall (s :: S). Term s (PMap keysort k v) -> Term s PData
pdataImpl Term s (PMap keysort k v)
x = DefaultFun -> Term s (PMap keysort k v :--> PData)
forall (s :: S) (a :: S -> Type). DefaultFun -> Term s a
punsafeBuiltin DefaultFun
PLC.MapData Term s (PMap keysort k v :--> PData)
-> Term s (PMap keysort k v) -> Term s PData
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap keysort k v)
x

-- | @since 2.0.0
instance PEq (PMap 'Sorted k v) where
  Term s (PMap 'Sorted k v)
x #== :: forall (s :: S).
Term s (PMap 'Sorted k v)
-> Term s (PMap 'Sorted k v) -> Term s PBool
#== Term s (PMap 'Sorted k v)
y = Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
forall (s :: S).
Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
peqViaData Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
-> Term s (PMap 'Sorted k v)
-> Term s (PMap 'Sorted k v :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v)
x Term s (PMap 'Sorted k v :--> PBool)
-> Term s (PMap 'Sorted k v) -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v)
y
    where
      peqViaData ::
        forall (s :: S).
        Term s (PMap 'Sorted k v :--> PMap 'Sorted k v :--> PBool)
      peqViaData :: forall (s :: S).
Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
peqViaData = (forall (s :: S).
 Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))
-> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))
 -> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))
-> (forall (s :: S).
    Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))
-> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
forall a b. (a -> b) -> a -> b
$ (Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v) -> Term s PBool)
-> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k v) -> Term s PBool)
-> Term s (c :--> (PMap 'Sorted k v :--> PBool))
plam ((Term s (PMap 'Sorted k v)
  -> Term s (PMap 'Sorted k v) -> Term s PBool)
 -> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))
-> (Term s (PMap 'Sorted k v)
    -> Term s (PMap 'Sorted k v) -> Term s PBool)
-> Term s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap 'Sorted k v)
m0 Term s (PMap 'Sorted k v)
m1 -> Term s (PMap 'Sorted k v) -> Term s (PAsData (PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s (PMap 'Sorted k v)
m0 Term s (PAsData (PMap 'Sorted k v))
-> Term s (PAsData (PMap 'Sorted k v)) -> Term s PBool
forall (s :: S).
Term s (PAsData (PMap 'Sorted k v))
-> Term s (PAsData (PMap 'Sorted k v)) -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PMap 'Sorted k v) -> Term s (PAsData (PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s (PMap 'Sorted k v)
m1

-- | @since 2.0.0
instance
  ( PTryFrom PData (PAsData k)
  , PTryFrom PData (PAsData v)
  ) =>
  PTryFrom PData (PAsData (PMap 'Unsorted k v))
  where
  type PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) = Mret (PMap 'Unsorted k v)
  ptryFrom' :: forall (s :: S) (r :: S -> Type).
Term s PData
-> ((Term s (PAsData (PMap 'Unsorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PMap 'Unsorted k v)),
   Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
-> ((Term s (PAsData (PMap 'Unsorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
    -> Term s r)
-> Term s r
forall (r :: S -> Type) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PMap 'Unsorted k v)),
    Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
 -> ((Term s (PAsData (PMap 'Unsorted k v)),
      Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PMap 'Unsorted k v)),
      Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
-> ((Term s (PAsData (PMap 'Unsorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Unsorted k v)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    Term s (PBuiltinList (PBuiltinPair PData PData))
opq' <- ((Term s (PBuiltinList (PBuiltinPair PData PData)) -> Term s r)
 -> Term s r)
-> TermCont s (Term s (PBuiltinList (PBuiltinPair PData PData)))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinList (PBuiltinPair PData PData)) -> Term s r)
  -> Term s r)
 -> TermCont s (Term s (PBuiltinList (PBuiltinPair PData PData))))
-> (Term s (PBuiltinList (PBuiltinPair PData PData))
    -> (Term s (PBuiltinList (PBuiltinPair PData PData)) -> Term s r)
    -> Term s r)
-> Term s (PBuiltinList (PBuiltinPair PData PData))
-> TermCont s (Term s (PBuiltinList (PBuiltinPair PData PData)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair PData PData))
-> (Term s (PBuiltinList (PBuiltinPair PData PData)) -> Term s r)
-> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinList (PBuiltinPair PData PData))
 -> TermCont s (Term s (PBuiltinList (PBuiltinPair PData PData))))
-> Term s (PBuiltinList (PBuiltinPair PData PData))
-> TermCont s (Term s (PBuiltinList (PBuiltinPair PData PData)))
forall a b. (a -> b) -> a -> b
$ Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
forall (s :: S).
Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
pasMap Term s (PData :--> PBuiltinList (PBuiltinPair PData PData))
-> Term s PData -> Term s (PBuiltinList (PBuiltinPair PData PData))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PData
opq
    Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
unwrapped <- ((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s r)
 -> Term s r)
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
        -> Term s r)
    -> Term s r)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s r)
-> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$ Term
  s
  ((PBuiltinPair PData PData
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair PData PData)
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap Term
  s
  ((PBuiltinPair PData PData
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair PData PData)
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinPair PData PData
      :--> PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair PData PData)
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinPair PData PData
   :--> PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S).
Term
  s
  (PBuiltinPair PData PData
   :--> PBuiltinPair (PAsData k) (PAsData v))
ptryFromPair Term
  s
  (PBuiltinList (PBuiltinPair PData PData)
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair PData PData))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair PData PData))
opq'
    (Term s (PAsData (PMap 'Unsorted k v)),
 Term s (PMap 'Unsorted k v))
-> TermCont
     s
     (Term s (PAsData (PMap 'Unsorted k v)),
      Term s (PMap 'Unsorted k v))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PMap 'Unsorted k v))
forall (b :: S -> Type) (a :: S -> Type) (s :: S).
Term s a -> Term s b
punsafeCoerce Term s PData
opq, PMap 'Unsorted k v s -> Term s (PMap 'Unsorted k v)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Unsorted k v s -> Term s (PMap 'Unsorted k v))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> PMap 'Unsorted k v s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PMap 'Unsorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Unsorted k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PMap 'Unsorted k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PMap 'Unsorted k v)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
unwrapped)
    where
      ptryFromPair ::
        forall (s :: S).
        Term s (PBuiltinPair PData PData :--> PBuiltinPair (PAsData k) (PAsData v))
      ptryFromPair :: forall (s :: S).
Term
  s
  (PBuiltinPair PData PData
   :--> PBuiltinPair (PAsData k) (PAsData v))
ptryFromPair = (Term s (PBuiltinPair PData PData)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinPair PData PData
      :--> PBuiltinPair (PAsData k) (PAsData v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (c :--> PBuiltinPair (PAsData k) (PAsData v))
plam ((Term s (PBuiltinPair PData PData)
  -> Term s (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term
      s
      (PBuiltinPair PData PData
       :--> PBuiltinPair (PAsData k) (PAsData v)))
-> (Term s (PBuiltinPair PData PData)
    -> Term s (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinPair PData PData
      :--> PBuiltinPair (PAsData k) (PAsData v))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair PData PData)
p ->
        Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin
          # ptryFrom (pfstBuiltin # p) fst
          # ptryFrom (psndBuiltin # p) fst

-- | @since 2.0.0
instance
  ( POrd k
  , PIsData k
  , PTryFrom PData (PAsData k)
  , PTryFrom PData (PAsData v)
  ) =>
  PTryFrom PData (PAsData (PMap 'Sorted k v))
  where
  type PTryFromExcess PData (PAsData (PMap 'Sorted k v)) = Mret (PMap 'Sorted k v)
  ptryFrom' :: forall (s :: S) (r :: S -> Type).
Term s PData
-> ((Term s (PAsData (PMap 'Sorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData (PMap 'Sorted k v)),
   Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
-> ((Term s (PAsData (PMap 'Sorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
    -> Term s r)
-> Term s r
forall (r :: S -> Type) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData (PMap 'Sorted k v)),
    Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
 -> ((Term s (PAsData (PMap 'Sorted k v)),
      Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PMap 'Sorted k v)),
      Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
-> ((Term s (PAsData (PMap 'Sorted k v)),
     Reduce (PTryFromExcess PData (PAsData (PMap 'Sorted k v)) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData (PMap 'Unsorted k v))
opq', Term s (PMap 'Unsorted k v)
_) <- (((Term s (PAsData (PMap 'Unsorted k v)),
   Term s (PMap 'Unsorted k v))
  -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PMap 'Unsorted k v)),
      Term s (PMap 'Unsorted k v))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData (PMap 'Unsorted k v)),
    Term s (PMap 'Unsorted k v))
   -> Term s r)
  -> Term s r)
 -> TermCont
      s
      (Term s (PAsData (PMap 'Unsorted k v)),
       Term s (PMap 'Unsorted k v)))
-> (((Term s (PAsData (PMap 'Unsorted k v)),
      Term s (PMap 'Unsorted k v))
     -> Term s r)
    -> Term s r)
-> TermCont
     s
     (Term s (PAsData (PMap 'Unsorted k v)),
      Term s (PMap 'Unsorted k v))
forall a b. (a -> b) -> a -> b
$ forall (b :: S -> Type) (a :: S -> Type) (s :: S) (r :: S -> Type).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData (PMap 'Unsorted k v)) Term s PData
opq
    Term s (PMap 'Sorted k v)
unwrapped <- ((Term s (PMap 'Sorted k v) -> Term s r) -> Term s r)
-> TermCont s (Term s (PMap 'Sorted k v))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PMap 'Sorted k v) -> Term s r) -> Term s r)
 -> TermCont s (Term s (PMap 'Sorted k v)))
-> ((Term s (PMap 'Sorted k v) -> Term s r) -> Term s r)
-> TermCont s (Term s (PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$ Term s (PMap 'Sorted k v)
-> (Term s (PMap 'Sorted k v) -> Term s r) -> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PMap 'Sorted k v)
 -> (Term s (PMap 'Sorted k v) -> Term s r) -> Term s r)
-> (Term s (PAsData (PMap 'Unsorted k v))
    -> Term s (PMap 'Sorted k v))
-> Term s (PAsData (PMap 'Unsorted k v))
-> (Term s (PMap 'Sorted k v) -> Term s r)
-> Term s r
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PMap 'Unsorted k v :--> PMap 'Sorted k v)
-> Term s (PMap 'Unsorted k v) -> Term s (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
papp Term s (PMap 'Unsorted k v :--> PMap 'Sorted k v)
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(POrd k, PIsData k) =>
Term s (PMap any k v :--> PMap 'Sorted k v)
passertSorted (Term s (PMap 'Unsorted k v) -> Term s (PMap 'Sorted k v))
-> (Term s (PAsData (PMap 'Unsorted k v))
    -> Term s (PMap 'Unsorted k v))
-> Term s (PAsData (PMap 'Unsorted k v))
-> Term s (PMap 'Sorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData (PMap 'Unsorted k v))
-> Term s (PMap 'Unsorted k v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PMap 'Unsorted k v))
 -> (Term s (PMap 'Sorted k v) -> Term s r) -> Term s r)
-> Term s (PAsData (PMap 'Unsorted k v))
-> (Term s (PMap 'Sorted k v) -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PMap 'Unsorted k v))
opq'
    (Term s (PAsData (PMap 'Sorted k v)), Term s (PMap 'Sorted k v))
-> TermCont
     s (Term s (PAsData (PMap 'Sorted k v)), Term s (PMap 'Sorted k v))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PData -> Term s (PAsData (PMap 'Sorted k v))
forall (b :: S -> Type) (a :: S -> Type) (s :: S).
Term s a -> Term s b
punsafeCoerce Term s PData
opq, Term s (PMap 'Sorted k v)
unwrapped)

-- | @since 2.0.0
data Commutativity = Commutative | NonCommutative
  deriving stock
    ( -- | @since 2.0.0
      Commutativity -> Commutativity -> Bool
(Commutativity -> Commutativity -> Bool)
-> (Commutativity -> Commutativity -> Bool) -> Eq Commutativity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Commutativity -> Commutativity -> Bool
== :: Commutativity -> Commutativity -> Bool
$c/= :: Commutativity -> Commutativity -> Bool
/= :: Commutativity -> Commutativity -> Bool
Eq
    , -- | @since 2.0.0
      Eq Commutativity
Eq Commutativity =>
(Commutativity -> Commutativity -> Ordering)
-> (Commutativity -> Commutativity -> Bool)
-> (Commutativity -> Commutativity -> Bool)
-> (Commutativity -> Commutativity -> Bool)
-> (Commutativity -> Commutativity -> Bool)
-> (Commutativity -> Commutativity -> Commutativity)
-> (Commutativity -> Commutativity -> Commutativity)
-> Ord Commutativity
Commutativity -> Commutativity -> Bool
Commutativity -> Commutativity -> Ordering
Commutativity -> Commutativity -> Commutativity
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Commutativity -> Commutativity -> Ordering
compare :: Commutativity -> Commutativity -> Ordering
$c< :: Commutativity -> Commutativity -> Bool
< :: Commutativity -> Commutativity -> Bool
$c<= :: Commutativity -> Commutativity -> Bool
<= :: Commutativity -> Commutativity -> Bool
$c> :: Commutativity -> Commutativity -> Bool
> :: Commutativity -> Commutativity -> Bool
$c>= :: Commutativity -> Commutativity -> Bool
>= :: Commutativity -> Commutativity -> Bool
$cmax :: Commutativity -> Commutativity -> Commutativity
max :: Commutativity -> Commutativity -> Commutativity
$cmin :: Commutativity -> Commutativity -> Commutativity
min :: Commutativity -> Commutativity -> Commutativity
Ord
    , -- | @since 2.0.0
      Int -> Commutativity -> ShowS
[Commutativity] -> ShowS
Commutativity -> String
(Int -> Commutativity -> ShowS)
-> (Commutativity -> String)
-> ([Commutativity] -> ShowS)
-> Show Commutativity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Commutativity -> ShowS
showsPrec :: Int -> Commutativity -> ShowS
$cshow :: Commutativity -> String
show :: Commutativity -> String
$cshowList :: [Commutativity] -> ShowS
showList :: [Commutativity] -> ShowS
Show
    )

-- TODO: Rename this, because the name is confusing.

{- | Given a 'PMap' of uncertain order, yield a 'PMap' that is known to be
sorted.

@since 2.0.0
-}
passertSorted ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (s :: S).
  ( POrd k
  , PIsData k
  ) =>
  Term s (PMap any k v :--> PMap 'Sorted k v)
passertSorted :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(POrd k, PIsData k) =>
Term s (PMap any k v :--> PMap 'Sorted k v)
passertSorted =
  let ()
_ = Proxy (k ~ k) -> ()
forall (c :: Constraint). c => Proxy c -> ()
witness (Proxy (k ~ k)
forall {k} (t :: k). Proxy t
Proxy :: Proxy (k ~ k))
   in ClosedTerm (PMap any k v :--> PMap 'Sorted k v)
-> Term s (PMap any k v :--> PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PMap any k v :--> PMap 'Sorted k v)
 -> Term s (PMap any k v :--> PMap 'Sorted k v))
-> ClosedTerm (PMap any k v :--> PMap 'Sorted k v)
-> Term s (PMap any k v :--> PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$
        (Term s (PMap any k v) -> Term s (PMap 'Sorted k v))
-> Term s (PMap any k v :--> PMap 'Sorted k v)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k v))
-> Term s (c :--> PMap 'Sorted k v)
plam ((Term s (PMap any k v) -> Term s (PMap 'Sorted k v))
 -> Term s (PMap any k v :--> PMap 'Sorted k v))
-> (Term s (PMap any k v) -> Term s (PMap 'Sorted k v))
-> Term s (PMap any k v :--> PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ \Term s (PMap any k v)
m ->
          (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> ((k :--> PBool) :--> PMap 'Sorted k v))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ((k :--> PBool) :--> PMap 'Sorted k v))
    -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((k :--> PBool) :--> PMap 'Sorted k v))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
            ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((k :--> PBool) :--> PMap 'Sorted k v))
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
                Term s k
-> (Term s k -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData k) -> Term s k) -> Term s (PAsData k) -> Term s k
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x) ((Term s k -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> (Term s k -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ \Term s k
k ->
                  (Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k v))
-> Term s (c :--> PMap 'Sorted k v)
plam ((Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> (Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ \Term s (k :--> PBool)
badKey ->
                    Term s PBool
-> Term s (PMap 'Sorted k v)
-> Term s (PMap 'Sorted k v)
-> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                      (Term s (k :--> PBool)
badKey Term s (k :--> PBool) -> Term s k -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k
k)
                      (Term s PString -> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
"unsorted map")
                      (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((k :--> PBool) :--> PMap 'Sorted k v))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs Term s ((k :--> PBool) :--> PMap 'Sorted k v)
-> Term s (k :--> PBool) -> Term s (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s k -> Term s PBool) -> Term s (k :--> PBool)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam (Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s k
k))
            )
            -- this is actually the empty map so we can
            -- safely assume that it is sorted
            (Term s ((k :--> PBool) :--> PMap 'Sorted k v)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a b. a -> b -> a
const (Term s ((k :--> PBool) :--> PMap 'Sorted k v)
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ((k :--> PBool) :--> PMap 'Sorted k v))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> (Term s (PMap 'Sorted k v)
    -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k v))
-> Term s (c :--> PMap 'Sorted k v)
plam ((Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> (Term s (PMap 'Sorted k v)
    -> Term s (k :--> PBool) -> Term s (PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PMap 'Sorted k v)
-> Term s (k :--> PBool) -> Term s (PMap 'Sorted k v)
forall a b. a -> b -> a
const (Term s (PMap 'Sorted k v)
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ((k :--> PBool) :--> PMap 'Sorted k v))
 -> Term s ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((k :--> PBool) :--> PMap 'Sorted k v))
-> Term s ((k :--> PBool) :--> PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ Term s (PMap any k v) -> Term s (PMap 'Sorted k v)
forall (b :: S -> Type) (a :: S -> Type) (s :: S).
Term s a -> Term s b
punsafeCoerce Term s (PMap any k v)
m)
            # pto m
            # plam (const $ pcon PFalse)

{- | Construct an empty 'PMap'.

@since 2.0.0
-}
pempty :: Term s (PMap 'Sorted k v)
pempty :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Term s (PMap 'Sorted k v)
pempty = Term s (PInner (PMap 'Sorted k v)) -> Term s (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type). Term s (PInner a) -> Term s a
punsafeDowncast Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
Term s (PInner (PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil

{- | Given a comparison function and a "zero" value, check whether a binary relation holds over
2 sorted 'PMap's.

= Important note

This is primarily intended to be used with 'PValue'. We assume that the comparison behaves like
a comparison would (thus, being at least a partial order, or possibly a total order or
equivalence), and that the starting value does not break it. Use with extreme care.

@since 2.0.0
-}
pcheckBinRel ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  Term
    s
    ( (v :--> v :--> PBool)
        :--> v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PBool
    )
pcheckBinRel :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term
  s
  ((v :--> (v :--> PBool))
   :--> (v
         :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
pcheckBinRel = ClosedTerm
  ((v :--> (v :--> PBool))
   :--> (v
         :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
-> Term
     s
     ((v :--> (v :--> PBool))
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> (v :--> PBool))
    :--> (v
          :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
 -> Term
      s
      ((v :--> (v :--> PBool))
       :--> (v
             :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))))
-> ClosedTerm
     ((v :--> (v :--> PBool))
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
-> Term
     s
     ((v :--> (v :--> PBool))
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
forall a b. (a -> b) -> a -> b
$
  (Term s (v :--> (v :--> PBool))
 -> Term s v
 -> Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v)
 -> Term s PBool)
-> Term
     s
     ((v :--> (v :--> PBool))
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s v
 -> Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v)
 -> Term s PBool)
-> Term
     s
     (c
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
plam ((Term s (v :--> (v :--> PBool))
  -> Term s v
  -> Term s (PMap 'Sorted k v)
  -> Term s (PMap 'Sorted k v)
  -> Term s PBool)
 -> Term
      s
      ((v :--> (v :--> PBool))
       :--> (v
             :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool)))))
-> (Term s (v :--> (v :--> PBool))
    -> Term s v
    -> Term s (PMap 'Sorted k v)
    -> Term s (PMap 'Sorted k v)
    -> Term s PBool)
-> Term
     s
     ((v :--> (v :--> PBool))
      :--> (v
            :--> (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PBool))))
forall a b. (a -> b) -> a -> b
$ \Term s (v :--> (v :--> PBool))
f Term s v
z Term s (PMap 'Sorted k v)
m1 Term s (PMap 'Sorted k v)
m2 ->
    let inner :: Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
inner = Term
  s
  (((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PBool))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBool)))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PBool))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBool)))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBool)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBool)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> PBool))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s PBool)
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBool)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s PBool)
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBool)))
plam ((Term
    s
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PBool))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s PBool)
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> PBool))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBool))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBool))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s PBool)
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBool)))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
self Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l1 Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l2 ->
          (Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s PBool)
-> Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (a :: S -> Type) (s :: S) (r :: S -> Type).
PElemConstraint PBuiltinList a =>
(Term s a -> Term s (PBuiltinList a) -> Term s r)
-> Term s r -> Term s (PBuiltinList a) -> Term s r
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
(PListLike list, PElemConstraint list a) =>
(Term s a -> Term s (list a) -> Term s r)
-> Term s r -> Term s (list a) -> Term s r
pelimList
            ( \Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
                Term s v -> (Term s v -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData v) -> Term s v) -> Term s (PAsData v) -> Term s v
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x) ((Term s v -> Term s PBool) -> Term s PBool)
-> (Term s v -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \Term s v
v1 ->
                  (Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s PBool)
-> Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (a :: S -> Type) (s :: S) (r :: S -> Type).
PElemConstraint PBuiltinList a =>
(Term s a -> Term s (PBuiltinList a) -> Term s r)
-> Term s r -> Term s (PBuiltinList a) -> Term s r
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
(PListLike list, PElemConstraint list a) =>
(Term s a -> Term s (list a) -> Term s r)
-> Term s r -> Term s (list a) -> Term s r
pelimList
                    ( \Term s (PBuiltinPair (PAsData k) (PAsData v))
y Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys -> TermCont s (Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont s (Term s PBool) -> Term s PBool)
-> TermCont s (Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ do
                        Term s v
v2 <- ((Term s v -> Term s PBool) -> Term s PBool)
-> TermCont s (Term s v)
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s v -> Term s PBool) -> Term s PBool)
 -> TermCont s (Term s v))
-> (Term s (PAsData v)
    -> (Term s v -> Term s PBool) -> Term s PBool)
-> Term s (PAsData v)
-> TermCont s (Term s v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s v -> (Term s v -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s v -> (Term s v -> Term s PBool) -> Term s PBool)
-> (Term s (PAsData v) -> Term s v)
-> Term s (PAsData v)
-> (Term s v -> Term s PBool)
-> Term s PBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData v) -> TermCont s (Term s v))
-> Term s (PAsData v) -> TermCont s (Term s v)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y
                        Term s k
k1 <- ((Term s k -> Term s PBool) -> Term s PBool)
-> TermCont s (Term s k)
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s k -> Term s PBool) -> Term s PBool)
 -> TermCont s (Term s k))
-> (Term s (PAsData k)
    -> (Term s k -> Term s PBool) -> Term s PBool)
-> Term s (PAsData k)
-> TermCont s (Term s k)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s k -> (Term s k -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s k -> (Term s k -> Term s PBool) -> Term s PBool)
-> (Term s (PAsData k) -> Term s k)
-> Term s (PAsData k)
-> (Term s k -> Term s PBool)
-> Term s PBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData k) -> TermCont s (Term s k))
-> Term s (PAsData k) -> TermCont s (Term s k)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x
                        Term s k
k2 <- ((Term s k -> Term s PBool) -> Term s PBool)
-> TermCont s (Term s k)
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s k -> Term s PBool) -> Term s PBool)
 -> TermCont s (Term s k))
-> (Term s (PAsData k)
    -> (Term s k -> Term s PBool) -> Term s PBool)
-> Term s (PAsData k)
-> TermCont s (Term s k)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s k -> (Term s k -> Term s PBool) -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s k -> (Term s k -> Term s PBool) -> Term s PBool)
-> (Term s (PAsData k) -> Term s k)
-> Term s (PAsData k)
-> (Term s k -> Term s PBool)
-> Term s PBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData k) -> TermCont s (Term s k))
-> Term s (PAsData k) -> TermCont s (Term s k)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y
                        Term s PBool -> TermCont s (Term s PBool)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure
                          (Term s PBool -> TermCont s (Term s PBool))
-> Term s PBool -> TermCont s (Term s PBool)
forall a b. (a -> b) -> a -> b
$ Term s PBool -> Term s PBool -> Term s PBool -> Term s PBool
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                            (Term s k
k1 Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s k
k2)
                            ( Term s (v :--> (v :--> PBool))
f
                                # v1
                                # v2
                                #&& self
                                # xs
                                # ys
                            )
                          (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term s PBool -> Term s PBool -> Term s PBool -> Term s PBool
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                            (Term s k
k1 Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s k
k2)
                            (Term s (v :--> (v :--> PBool))
f Term s (v :--> (v :--> PBool)) -> Term s v -> Term s (v :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
v1 Term s (v :--> PBool) -> Term s v -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
z Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#&& Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l2)
                          (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term s (v :--> (v :--> PBool))
f
                            # z
                            # v2
                            #&& self
                            # l1
                            # ys
                    )
                    ( Term s (v :--> (v :--> PBool))
f
                        # v1
                        # z
                        #&& PPrelude.pall
                        # plam (\p -> f # pfromData (psndBuiltin # p) # z)
                        # xs
                    )
                    Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l2
            )
            (Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s ((a :--> PBool) :--> (list a :--> PBool))
PPrelude.pall Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam (\Term s (PBuiltinPair (PAsData k) (PAsData v))
p -> Term s (v :--> (v :--> PBool))
f Term s (v :--> (v :--> PBool)) -> Term s v -> Term s (v :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
z Term s (v :--> PBool) -> Term s v -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData v) -> Term s v) -> Term s (PAsData v) -> Term s v
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
p) Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l2)
            Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
l1
     in Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
inner Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
m1 Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
m2

{- | Verifies all values in the map satisfy the given predicate.

@since 2.0.0
-}
pall ::
  forall (any :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type) (s :: S).
  PIsData v =>
  Term s ((v :--> PBool) :--> PMap any k v :--> PBool)
pall :: forall (any :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
PIsData v =>
Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
pall = ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
 -> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool)))
-> ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a b. (a -> b) -> a -> b
$
  (Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap any k v) -> Term s PBool)
-> Term s (c :--> (PMap any k v :--> PBool))
plam ((Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
 -> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool)))
-> (Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (v :--> PBool)
pred Term s (PMap any k v)
m ->
    Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s ((a :--> PBool) :--> (list a :--> PBool))
PPrelude.pall Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam (\Term s (PBuiltinPair (PAsData k) (PAsData v))
pair -> Term s (v :--> PBool)
pred Term s (v :--> PBool) -> Term s v -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData v) -> Term s v) -> Term s (PAsData v) -> Term s v
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
pair) Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap any k v) -> Term s (PInner (PMap any k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap any k v)
m

{- | Build the union of two 'PMap's, merging values that share the same key using the
given function.

@since 2.0.0
-}
punionResolvingCollisionsWith ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  Commutativity ->
  Term s ((v :--> v :--> v) :--> PMap 'Sorted k v :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
punionResolvingCollisionsWith :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Commutativity
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
punionResolvingCollisionsWith Commutativity
commutativity =
  ClosedTerm
  ((v :--> (v :--> v))
   :--> (PMap 'Sorted k v
         :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> (v :--> v))
    :--> (PMap 'Sorted k v
          :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
    (Term s (v :--> (v :--> v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (c
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (v :--> (v :--> v))
  -> Term
       s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (v :--> (v :--> v))
    -> Term
         s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
      SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler k v s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s)
-> Term s (v :--> (v :--> v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
unionMergeHandler Commutativity
commutativity

{- | Build the union of two 'PMap's, merging values that share the same key using the
given function.

@since 2.1.1
-}
punionResolvingCollisionsWithData ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  ) =>
  Commutativity ->
  Term
    s
    ( (PAsData v :--> PAsData v :--> PAsData v)
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
    )
punionResolvingCollisionsWithData :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k) =>
Commutativity
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
punionResolvingCollisionsWithData Commutativity
commutativity =
  ClosedTerm
  ((PAsData v :--> (PAsData v :--> PAsData v))
   :--> (PMap 'Sorted k v
         :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PAsData v :--> (PAsData v :--> PAsData v))
    :--> (PMap 'Sorted k v
          :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((PAsData v :--> (PAsData v :--> PAsData v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
    (Term s (PAsData v :--> (PAsData v :--> PAsData v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (c
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (PAsData v :--> (PAsData v :--> PAsData v))
  -> Term
       s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((PAsData v :--> (PAsData v :--> PAsData v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (PAsData v :--> (PAsData v :--> PAsData v))
    -> Term
         s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
      SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWithData (SomeMergeHandler (PAsData k) (PAsData v) s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (PAsData v :--> (PAsData v :--> PAsData v))
    -> SomeMergeHandler (PAsData k) (PAsData v) s)
-> Term s (PAsData v :--> (PAsData v :--> PAsData v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Commutativity
-> Term s (PAsData v :--> (PAsData v :--> PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
unionMergeHandler Commutativity
commutativity

{- | Maps and filters the map, much like 'Data.PPrelude.mapMaybe'.

@since 2.0.0
-}
pmapMaybe ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  ( PIsData a
  , PIsData b
  ) =>
  Term s ((a :--> PMaybe b) :--> PMap g k a :--> PMap g k b)
pmapMaybe :: forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PIsData a, PIsData b) =>
Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
pmapMaybe = ClosedTerm ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
-> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
 -> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b)))
-> ClosedTerm ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
-> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$
  (Term s (a :--> PMaybe b) -> Term s (PMap g k a :--> PMap g k b))
-> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap g k a :--> PMap g k b))
-> Term s (c :--> (PMap g k a :--> PMap g k b))
plam ((Term s (a :--> PMaybe b) -> Term s (PMap g k a :--> PMap g k b))
 -> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b)))
-> (Term s (a :--> PMaybe b)
    -> Term s (PMap g k a :--> PMap g k b))
-> Term s ((a :--> PMaybe b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$ \Term s (a :--> PMaybe b)
f -> Term
  s
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
Term
  s
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
pmapMaybeData Term
  s
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
-> Term s (PAsData a :--> PMaybe (PAsData b))
-> Term s (PMap g k a :--> PMap g k b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term s (PAsData a) -> Term s (PMaybe (PAsData b)))
-> Term s (PAsData a :--> PMaybe (PAsData b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMaybe (PAsData b)))
-> Term s (c :--> PMaybe (PAsData b))
plam ((Term s (PAsData a) -> Term s (PMaybe (PAsData b)))
 -> Term s (PAsData a :--> PMaybe (PAsData b)))
-> (Term s (PAsData a) -> Term s (PMaybe (PAsData b)))
-> Term s (PAsData a :--> PMaybe (PAsData b))
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData a)
v -> Term s (PMaybe b)
-> (PMaybe b s -> Term s (PMaybe (PAsData b)))
-> Term s (PMaybe (PAsData b))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (a :--> PMaybe b)
f Term s (a :--> PMaybe b) -> Term s a -> Term s (PMaybe b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData a) -> Term s a
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData a)
v) ((PMaybe b s -> Term s (PMaybe (PAsData b)))
 -> Term s (PMaybe (PAsData b)))
-> (PMaybe b s -> Term s (PMaybe (PAsData b)))
-> Term s (PMaybe (PAsData b))
forall a b. (a -> b) -> a -> b
$ \case
    PMaybe b s
PNothing -> PMaybe (PAsData b) s -> Term s (PMaybe (PAsData b))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PMaybe (PAsData b) s
forall (a :: S -> Type) (s :: S). PMaybe a s
PNothing
    PJust Term s b
v' -> PMaybe (PAsData b) s -> Term s (PMaybe (PAsData b))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMaybe (PAsData b) s -> Term s (PMaybe (PAsData b)))
-> PMaybe (PAsData b) s -> Term s (PMaybe (PAsData b))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData b) -> PMaybe (PAsData b) s
forall (a :: S -> Type) (s :: S). Term s a -> PMaybe a s
PJust (Term s b -> Term s (PAsData b)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s b
v')

{- | As 'pmapMaybe', but over Data representation.

@since 2.0.0
-}
pmapMaybeData ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  Term s ((PAsData a :--> PMaybe (PAsData b)) :--> PMap g k a :--> PMap g k b)
pmapMaybeData :: forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
Term
  s
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
pmapMaybeData = ClosedTerm
  ((PAsData a :--> PMaybe (PAsData b))
   :--> (PMap g k a :--> PMap g k b))
-> Term
     s
     ((PAsData a :--> PMaybe (PAsData b))
      :--> (PMap g k a :--> PMap g k b))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PAsData a :--> PMaybe (PAsData b))
    :--> (PMap g k a :--> PMap g k b))
 -> Term
      s
      ((PAsData a :--> PMaybe (PAsData b))
       :--> (PMap g k a :--> PMap g k b)))
-> ClosedTerm
     ((PAsData a :--> PMaybe (PAsData b))
      :--> (PMap g k a :--> PMap g k b))
-> Term
     s
     ((PAsData a :--> PMaybe (PAsData b))
      :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$
  (Term s (PAsData a :--> PMaybe (PAsData b))
 -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term
     s
     ((PAsData a :--> PMaybe (PAsData b))
      :--> (PMap g k a :--> PMap g k b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term s (c :--> (PMap g k a :--> PMap g k b))
plam ((Term s (PAsData a :--> PMaybe (PAsData b))
  -> Term s (PMap g k a) -> Term s (PMap g k b))
 -> Term
      s
      ((PAsData a :--> PMaybe (PAsData b))
       :--> (PMap g k a :--> PMap g k b)))
-> (Term s (PAsData a :--> PMaybe (PAsData b))
    -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term
     s
     ((PAsData a :--> PMaybe (PAsData b))
      :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData a :--> PMaybe (PAsData b))
f Term s (PMap g k a)
m ->
    PMap g k b s -> Term s (PMap g k b)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap g k b s -> Term s (PMap g k b))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> PMap g k b s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap g k b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> PMap g k b s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s (PMap g k b))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap g k b)
forall a b. (a -> b) -> a -> b
$
      (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s (PBuiltinPair (PAsData k) (PAsData a))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
        ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
self Term s (PBuiltinPair (PAsData k) (PAsData a))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
xs ->
            Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
xs) ((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
xs' ->
              Term s (PMaybe (PAsData b))
-> (PMaybe (PAsData b) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (PAsData a :--> PMaybe (PAsData b))
f Term s (PAsData a :--> PMaybe (PAsData b))
-> Term s (PAsData a) -> Term s (PMaybe (PAsData b))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PBuiltinPair (PAsData k) (PAsData a) :--> PAsData a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData a) :--> PAsData a)
-> Term s (PBuiltinPair (PAsData k) (PAsData a))
-> Term s (PAsData a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData a))
x) ((PMaybe (PAsData b) s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (PMaybe (PAsData b) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall a b. (a -> b) -> a -> b
$ \case
                PMaybe (PAsData b) s
PNothing -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
xs'
                PJust Term s (PAsData b)
v -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData b)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData b)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term s (PBuiltinPair (PAsData k) (PAsData b))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PAsData k
   :--> (PAsData b :--> PBuiltinPair (PAsData k) (PAsData b)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin Term
  s
  (PAsData k
   :--> (PAsData b :--> PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PAsData k)
-> Term s (PAsData b :--> PBuiltinPair (PAsData k) (PAsData b))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData a) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData a) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData a))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData a))
x) Term s (PAsData b :--> PBuiltinPair (PAsData k) (PAsData b))
-> Term s (PAsData b)
-> Term s (PBuiltinPair (PAsData k) (PAsData b))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData b)
v) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
xs'
        )
        (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall a b. a -> b -> a
const Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil)
        # pto m

{- | Tests whether the map is empty.

@since 2.0.0
-}
pnull ::
  forall (any :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type) (s :: S).
  Term s (PMap any k v :--> PBool)
pnull :: forall (any :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PMap any k v :--> PBool)
pnull = (Term s (PMap any k v) -> Term s PBool)
-> Term s (PMap any k v :--> PBool)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam (\Term s (PMap any k v)
m -> Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a :--> PBool)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> PBool)
PPrelude.pnull Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap any k v) -> Term s (PInner (PMap any k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap any k v)
m)

{- | Applies a function to every value in the map, much like 'Data.PPrelude.map'.

@since 2.0.0
-}
pmap ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  ( PIsData a
  , PIsData b
  ) =>
  Term s ((a :--> b) :--> PMap g k a :--> PMap g k b)
pmap :: forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PIsData a, PIsData b) =>
Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
pmap = ClosedTerm ((a :--> b) :--> (PMap g k a :--> PMap g k b))
-> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm ((a :--> b) :--> (PMap g k a :--> PMap g k b))
 -> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b)))
-> ClosedTerm ((a :--> b) :--> (PMap g k a :--> PMap g k b))
-> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$
  (Term s (a :--> b) -> Term s (PMap g k a :--> PMap g k b))
-> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap g k a :--> PMap g k b))
-> Term s (c :--> (PMap g k a :--> PMap g k b))
plam ((Term s (a :--> b) -> Term s (PMap g k a :--> PMap g k b))
 -> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b)))
-> (Term s (a :--> b) -> Term s (PMap g k a :--> PMap g k b))
-> Term s ((a :--> b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$
    \Term s (a :--> b)
f -> Term
  s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
Term
  s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
pmapData Term
  s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
-> Term s (PAsData a :--> PAsData b)
-> Term s (PMap g k a :--> PMap g k b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term s (PAsData a) -> Term s (PAsData b))
-> Term s (PAsData a :--> PAsData b)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PAsData b)) -> Term s (c :--> PAsData b)
plam ((Term s (PAsData a) -> Term s (PAsData b))
 -> Term s (PAsData a :--> PAsData b))
-> (Term s (PAsData a) -> Term s (PAsData b))
-> Term s (PAsData a :--> PAsData b)
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData a)
v -> Term s b -> Term s (PAsData b)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s (a :--> b)
f Term s (a :--> b) -> Term s a -> Term s b
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData a) -> Term s a
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData a)
v)

{- | As 'pmap', but gives key access as well.

@since 2.1.1
-}
pmapWithKey ::
  forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (keysort :: KeyGuarantees) (s :: S).
  ( PIsData k
  , PIsData a
  , PIsData b
  ) =>
  Term s ((k :--> a :--> b) :--> PMap keysort k a :--> PMap 'Unsorted k b)
pmapWithKey :: forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type)
       (keysort :: KeyGuarantees) (s :: S).
(PIsData k, PIsData a, PIsData b) =>
Term
  s
  ((k :--> (a :--> b))
   :--> (PMap keysort k a :--> PMap 'Unsorted k b))
pmapWithKey = ClosedTerm
  ((k :--> (a :--> b))
   :--> (PMap keysort k a :--> PMap 'Unsorted k b))
-> Term
     s
     ((k :--> (a :--> b))
      :--> (PMap keysort k a :--> PMap 'Unsorted k b))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((k :--> (a :--> b))
    :--> (PMap keysort k a :--> PMap 'Unsorted k b))
 -> Term
      s
      ((k :--> (a :--> b))
       :--> (PMap keysort k a :--> PMap 'Unsorted k b)))
-> ClosedTerm
     ((k :--> (a :--> b))
      :--> (PMap keysort k a :--> PMap 'Unsorted k b))
-> Term
     s
     ((k :--> (a :--> b))
      :--> (PMap keysort k a :--> PMap 'Unsorted k b))
forall a b. (a -> b) -> a -> b
$
  (Term s (k :--> (a :--> b))
 -> Term s (PMap keysort k a) -> Term s (PMap 'Unsorted k b))
-> Term
     s
     ((k :--> (a :--> b))
      :--> (PMap keysort k a :--> PMap 'Unsorted k b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PMap keysort k a) -> Term s (PMap 'Unsorted k b))
-> Term s (c :--> (PMap keysort k a :--> PMap 'Unsorted k b))
plam ((Term s (k :--> (a :--> b))
  -> Term s (PMap keysort k a) -> Term s (PMap 'Unsorted k b))
 -> Term
      s
      ((k :--> (a :--> b))
       :--> (PMap keysort k a :--> PMap 'Unsorted k b)))
-> (Term s (k :--> (a :--> b))
    -> Term s (PMap keysort k a) -> Term s (PMap 'Unsorted k b))
-> Term
     s
     ((k :--> (a :--> b))
      :--> (PMap keysort k a :--> PMap 'Unsorted k b))
forall a b. (a -> b) -> a -> b
$ \Term s (k :--> (a :--> b))
f Term s (PMap keysort k a)
kvs ->
    Term s (PMap keysort k a)
-> (PMap keysort k a s -> Term s (PMap 'Unsorted k b))
-> Term s (PMap 'Unsorted k b)
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap keysort k a)
kvs ((PMap keysort k a s -> Term s (PMap 'Unsorted k b))
 -> Term s (PMap 'Unsorted k b))
-> (PMap keysort k a s -> Term s (PMap 'Unsorted k b))
-> Term s (PMap 'Unsorted k b)
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
kvs') ->
      PMap 'Unsorted k b s -> Term s (PMap 'Unsorted k b)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Unsorted k b s -> Term s (PMap 'Unsorted k b))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> PMap 'Unsorted k b s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap 'Unsorted k b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> PMap 'Unsorted k b s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s (PMap 'Unsorted k b))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap 'Unsorted k b)
forall a b. (a -> b) -> a -> b
$
        Term
  s
  ((PBuiltinPair (PAsData k) (PAsData a)
    :--> PBuiltinPair (PAsData k) (PAsData b))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap
          # plam
            ( \x ->
                plet (pkvPairKey # x) $ \key ->
                  ppairDataBuiltin
                    # pdata key
                    #$ pdata
                    $ f # key # (pkvPairValue # x)
            )
          # kvs'

{- | As 'pmap', but over Data representations.

@since 2.0.0
-}
pmapData ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  Term s ((PAsData a :--> PAsData b) :--> PMap g k a :--> PMap g k b)
pmapData :: forall (g :: KeyGuarantees) (k :: S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
Term
  s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
pmapData = ClosedTerm
  ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
-> Term
     s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
 -> Term
      s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b)))
-> ClosedTerm
     ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
-> Term
     s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$
  (Term s (PAsData a :--> PAsData b)
 -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term
     s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term s (c :--> (PMap g k a :--> PMap g k b))
plam ((Term s (PAsData a :--> PAsData b)
  -> Term s (PMap g k a) -> Term s (PMap g k b))
 -> Term
      s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b)))
-> (Term s (PAsData a :--> PAsData b)
    -> Term s (PMap g k a) -> Term s (PMap g k b))
-> Term
     s ((PAsData a :--> PAsData b) :--> (PMap g k a :--> PMap g k b))
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData a :--> PAsData b)
f Term s (PMap g k a)
m ->
    PMap g k b s -> Term s (PMap g k b)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap g k b s -> Term s (PMap g k b))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> PMap g k b s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap g k b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> PMap g k b s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s (PMap g k b))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PMap g k b)
forall a b. (a -> b) -> a -> b
$
      (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s (PBuiltinPair (PAsData k) (PAsData a))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
        ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
self Term s (PBuiltinPair (PAsData k) (PAsData a))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
xs ->
            Term
  s
  (PBuiltinPair (PAsData k) (PAsData b)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
              # (ppairDataBuiltin # (pfstBuiltin # x) # (f #$ psndBuiltin # x))
              # (self # xs)
        )
        (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall a b. a -> b -> a
const Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil)
        # pto m

{- | Look up the given key in a 'PMap'.

@since 2.1.1
-}
plookup ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (s :: S).
  ( PIsData k
  , PIsData v
  ) =>
  Term s (k :--> PMap any k v :--> PMaybe v)
plookup :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap any k v :--> PMaybe v))
plookup = ClosedTerm (k :--> (PMap any k v :--> PMaybe v))
-> Term s (k :--> (PMap any k v :--> PMaybe v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (k :--> (PMap any k v :--> PMaybe v))
 -> Term s (k :--> (PMap any k v :--> PMaybe v)))
-> ClosedTerm (k :--> (PMap any k v :--> PMaybe v))
-> Term s (k :--> (PMap any k v :--> PMaybe v))
forall a b. (a -> b) -> a -> b
$
  (Term s k -> Term s (PMap any k v :--> PMaybe v))
-> Term s (k :--> (PMap any k v :--> PMaybe v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap any k v :--> PMaybe v))
-> Term s (c :--> (PMap any k v :--> PMaybe v))
plam ((Term s k -> Term s (PMap any k v :--> PMaybe v))
 -> Term s (k :--> (PMap any k v :--> PMaybe v)))
-> (Term s k -> Term s (PMap any k v :--> PMaybe v))
-> Term s (k :--> (PMap any k v :--> PMaybe v))
forall a b. (a -> b) -> a -> b
$ \Term s k
key ->
    Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe v)
   :--> (PAsData k :--> (PMap any k v :--> PMaybe v)))
forall (s :: S) (k :: S -> Type) (v :: S -> Type) (x :: S -> Type)
       (any :: KeyGuarantees).
Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
   :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
plookupDataWith
      # phoistAcyclic (plam $ \pair -> pcon $ PJust $ pfromData $ psndBuiltin # pair)
      # pdata key

{- | As 'plookup', but errors when the key is missing.

@since 2.1.1
-}
ptryLookup ::
  forall (k :: S -> Type) (v :: S -> Type) (keys :: KeyGuarantees) (s :: S).
  ( PIsData k
  , PIsData v
  ) =>
  Term s (k :--> PMap keys k v :--> v)
ptryLookup :: forall (k :: S -> Type) (v :: S -> Type) (keys :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap keys k v :--> v))
ptryLookup = ClosedTerm (k :--> (PMap keys k v :--> v))
-> Term s (k :--> (PMap keys k v :--> v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (k :--> (PMap keys k v :--> v))
 -> Term s (k :--> (PMap keys k v :--> v)))
-> ClosedTerm (k :--> (PMap keys k v :--> v))
-> Term s (k :--> (PMap keys k v :--> v))
forall a b. (a -> b) -> a -> b
$
  (Term s k -> Term s (PMap keys k v) -> Term s v)
-> Term s (k :--> (PMap keys k v :--> v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap keys k v) -> Term s v)
-> Term s (c :--> (PMap keys k v :--> v))
plam ((Term s k -> Term s (PMap keys k v) -> Term s v)
 -> Term s (k :--> (PMap keys k v :--> v)))
-> (Term s k -> Term s (PMap keys k v) -> Term s v)
-> Term s (k :--> (PMap keys k v :--> v))
forall a b. (a -> b) -> a -> b
$ \Term s k
k Term s (PMap keys k v)
kvs ->
    Term s (PString :--> (PMaybe v :--> v))
forall (a :: S -> Type) (s :: S).
Term s (PString :--> (PMaybe a :--> a))
passertPJust
      # "plookupPartial: No value found for key."
      # (plookup # k # kvs)

{- | as 'plookup', except over Data representation.

@since 2.1.1
-}
plookupData ::
  Term s (PAsData k :--> PMap any k v :--> PMaybe (PAsData v))
plookupData :: forall (s :: S) (k :: S -> Type) (any :: KeyGuarantees)
       (v :: S -> Type).
Term s (PAsData k :--> (PMap any k v :--> PMaybe (PAsData v)))
plookupData = Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
   :--> (PAsData k :--> (PMap any k v :--> PMaybe (PAsData v))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type) (x :: S -> Type)
       (any :: KeyGuarantees).
Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
   :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
plookupDataWith Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
   :--> (PAsData k :--> (PMap any k v :--> PMaybe (PAsData v))))
-> Term
     s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
-> Term s (PAsData k :--> (PMap any k v :--> PMaybe (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# ClosedTerm
  (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
-> Term
     s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PMaybe (PAsData v)))
-> Term
     s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMaybe (PAsData v)))
-> Term s (c :--> PMaybe (PAsData v))
plam ((Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PMaybe (PAsData v)))
 -> Term
      s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v)))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PMaybe (PAsData v)))
-> Term
     s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe (PAsData v))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData k) (PAsData v))
pair -> PMaybe (PAsData v) s -> Term s (PMaybe (PAsData v))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMaybe (PAsData v) s -> Term s (PMaybe (PAsData v)))
-> PMaybe (PAsData v) s -> Term s (PMaybe (PAsData v))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData v) -> PMaybe (PAsData v) s
forall (a :: S -> Type) (s :: S). Term s a -> PMaybe a s
PJust (Term s (PAsData v) -> PMaybe (PAsData v) s)
-> Term s (PAsData v) -> PMaybe (PAsData v) s
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
pair)

{- | Look up the given key data in a 'PMap', applying the given function to the found key-value pair.

@since 2.1.1
-}
plookupDataWith ::
  Term
    s
    ( (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
        :--> PAsData k
        :--> PMap any k v
        :--> PMaybe x
    )
plookupDataWith :: forall (s :: S) (k :: S -> Type) (v :: S -> Type) (x :: S -> Type)
       (any :: KeyGuarantees).
Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
   :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
plookupDataWith = ClosedTerm
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
   :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
      :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
    :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
 -> Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
       :--> (PAsData k :--> (PMap any k v :--> PMaybe x))))
-> ClosedTerm
     ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
      :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
      :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
forall a b. (a -> b) -> a -> b
$
  (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
 -> Term s (PAsData k)
 -> Term s (PMap any k v)
 -> Term s (PMaybe x))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
      :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PAsData k)
 -> Term s (PMap any k v)
 -> Term s (PMaybe x))
-> Term s (c :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
plam ((Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
  -> Term s (PAsData k)
  -> Term s (PMap any k v)
  -> Term s (PMaybe x))
 -> Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
       :--> (PAsData k :--> (PMap any k v :--> PMaybe x))))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
    -> Term s (PAsData k)
    -> Term s (PMap any k v)
    -> Term s (PMaybe x))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
      :--> (PAsData k :--> (PMap any k v :--> PMaybe x)))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
unwrap Term s (PAsData k)
key Term s (PMap any k v)
m ->
    (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PMaybe x))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
    -> Term s (PMaybe x))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
      ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
          Term s PBool
-> Term s (PMaybe x) -> Term s (PMaybe x) -> Term s (PMaybe x)
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
            (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (s :: S).
Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData k)
key)
            (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
unwrap Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PMaybe x)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PMaybe x)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x)
            (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PMaybe x)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs)
      )
      (Term s (PMaybe x)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
-> Term s (PMaybe x)
forall a b. a -> b -> a
const (Term s (PMaybe x)
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
 -> Term s (PMaybe x))
-> Term s (PMaybe x)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PMaybe x)
-> Term s (PMaybe x)
forall a b. (a -> b) -> a -> b
$ PMaybe x s -> Term s (PMaybe x)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PMaybe x s
forall (a :: S -> Type) (s :: S). PMaybe a s
PNothing)
      # pto m

{- | Construct a singleton 'PMap' with the given key and value.

@since 2.1.1
-}
psingleton ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , PIsData v
  ) =>
  Term s (k :--> v :--> PMap 'Sorted k v)
psingleton :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (v :--> PMap 'Sorted k v))
psingleton = ClosedTerm (k :--> (v :--> PMap 'Sorted k v))
-> Term s (k :--> (v :--> PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (k :--> (v :--> PMap 'Sorted k v))
 -> Term s (k :--> (v :--> PMap 'Sorted k v)))
-> ClosedTerm (k :--> (v :--> PMap 'Sorted k v))
-> Term s (k :--> (v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$ (Term s k -> Term s v -> Term s (PMap 'Sorted k v))
-> Term s (k :--> (v :--> PMap 'Sorted k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s v -> Term s (PMap 'Sorted k v))
-> Term s (c :--> (v :--> PMap 'Sorted k v))
plam ((Term s k -> Term s v -> Term s (PMap 'Sorted k v))
 -> Term s (k :--> (v :--> PMap 'Sorted k v)))
-> (Term s k -> Term s v -> Term s (PMap 'Sorted k v))
-> Term s (k :--> (v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$ \Term s k
key Term s v
value -> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
psingletonData Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
-> Term s (PAsData k) -> Term s (PAsData v :--> PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k -> Term s (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s k
key Term s (PAsData v :--> PMap 'Sorted k v)
-> Term s (PAsData v) -> Term s (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s v
value

{- | Construct a singleton 'PMap' with the given data-encoded key and value.

@since 2.1.1
-}
psingletonData ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  Term s (PAsData k :--> PAsData v :--> PMap 'Sorted k v)
psingletonData :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
psingletonData = ClosedTerm (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
-> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
 -> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v)))
-> ClosedTerm (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
-> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
  (Term s (PAsData k)
 -> Term s (PAsData v) -> Term s (PMap 'Sorted k v))
-> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PAsData v) -> Term s (PMap 'Sorted k v))
-> Term s (c :--> (PAsData v :--> PMap 'Sorted k v))
plam ((Term s (PAsData k)
  -> Term s (PAsData v) -> Term s (PMap 'Sorted k v))
 -> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v)))
-> (Term s (PAsData k)
    -> Term s (PAsData v) -> Term s (PMap 'Sorted k v))
-> Term s (PAsData k :--> (PAsData v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
    \Term s (PAsData k)
key Term s (PAsData v)
value -> Term s (PInner (PMap 'Sorted k v)) -> Term s (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type). Term s (PInner a) -> Term s a
punsafeDowncast (Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PAsData k)
-> Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData k)
key Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData v)
value) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil)

{- | Look up the given key in a 'PMap'; return the default if the key is
 absent or apply the argument function to the value data if present.

 @since 2.1.1
-}
pfoldAt ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (r :: S -> Type) (s :: S).
  PIsData k =>
  Term s (k :--> r :--> (PAsData v :--> r) :--> PMap any k v :--> r)
pfoldAt :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (r :: S -> Type) (s :: S).
PIsData k =>
Term
  s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
pfoldAt = ClosedTerm
  (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
 -> Term
      s
      (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r)))))
-> ClosedTerm
     (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a b. (a -> b) -> a -> b
$
  (Term s k
 -> Term s (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s (c :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
plam ((Term s k
  -> Term s (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
 -> Term
      s
      (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r)))))
-> (Term s k
    -> Term s (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s (k :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a b. (a -> b) -> a -> b
$
    \Term s k
key -> Term
  s
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (r :: S -> Type) (s :: S).
Term
  s
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
pfoldAtData Term
  s
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term s (PAsData k)
-> Term s (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k -> Term s (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s k
key

{- | Look up the given key data in a 'PMap'; return the default if the key is
 absent or apply the argument function to the value data if present.

 @since 2.1.1
-}
pfoldAtData ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (r :: S -> Type) (s :: S).
  Term s (PAsData k :--> r :--> (PAsData v :--> r) :--> PMap any k v :--> r)
pfoldAtData :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (r :: S -> Type) (s :: S).
Term
  s
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
pfoldAtData = ClosedTerm
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s
     (PAsData k
      :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PAsData k
    :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
 -> Term
      s
      (PAsData k
       :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r)))))
-> ClosedTerm
     (PAsData k
      :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
-> Term
     s
     (PAsData k
      :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a b. (a -> b) -> a -> b
$
  (Term s (PAsData k)
 -> Term s r
 -> Term s (PAsData v :--> r)
 -> Term s (PMap any k v)
 -> Term s r)
-> Term
     s
     (PAsData k
      :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s r
 -> Term s (PAsData v :--> r)
 -> Term s (PMap any k v)
 -> Term s r)
-> Term
     s (c :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
plam ((Term s (PAsData k)
  -> Term s r
  -> Term s (PAsData v :--> r)
  -> Term s (PMap any k v)
  -> Term s r)
 -> Term
      s
      (PAsData k
       :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r)))))
-> (Term s (PAsData k)
    -> Term s r
    -> Term s (PAsData v :--> r)
    -> Term s (PMap any k v)
    -> Term s r)
-> Term
     s
     (PAsData k
      :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
forall a b. (a -> b) -> a -> b
$ \Term s (PAsData k)
key Term s r
def Term s (PAsData v :--> r)
apply Term s (PMap any k v)
m ->
    (Term
   s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s r)
-> (Term
      s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
    -> Term s r)
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
      ( \Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
          Term s PBool -> Term s r -> Term s r -> Term s r
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
            (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (s :: S).
Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData k)
key)
            (Term s (PAsData v :--> r)
apply Term s (PAsData v :--> r) -> Term s (PAsData v) -> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x)
            (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
self Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s r
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs)
      )
      (Term s r
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> r)
-> Term s r
forall a b. a -> b -> a
const Term s r
def)
      # pto m

{- | Build the union of two 'PMap's. Take the value from the left argument for colliding keys.

 Prefer this over 'punionResolvingCollisionsWith NonCommutative # plam const'. It performs better.

 @since 2.1.1
-}
pleftBiasedUnion ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  Term s (PMap 'Sorted k v :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pleftBiasedUnion :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term
  s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pleftBiasedUnion =
  ClosedTerm
  (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> ClosedTerm
     (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
    SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler k v s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
      MergeHandler_ (->) (Term s k) (Term s v) -> SomeMergeHandler k v s
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler k v s)
-> MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler k v s
forall a b. (a -> b) -> a -> b
$
        BothPresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler (Bool -> BothPresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
Bool -> BothPresentHandler_ f k v
PassArg Bool
True) OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne

{- | Difference of two maps. Return elements of the first map not existing in the second map.

@since 2.1.1
-}
pdifference ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , POrd k
  , PIsData v
  ) =>
  Term s (PMap 'Sorted k v :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pdifference :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, POrd k, PIsData v) =>
Term
  s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pdifference =
  ClosedTerm
  (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> ClosedTerm
     (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
    SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler k v s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$
      MergeHandler_ (->) (Term s k) (Term s v) -> SomeMergeHandler k v s
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler k v s)
-> MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler k v s
forall a b. (a -> b) -> a -> b
$
        BothPresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler BothPresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. BothPresentHandler_ f k v
DropBoth OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
DropOne

{- | Tests if anu value in the map satisfies the given predicate.

@since 2.1.1
-}
pany ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (s :: S).
  PIsData v =>
  Term s ((v :--> PBool) :--> PMap any k v :--> PBool)
pany :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
PIsData v =>
Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
pany = ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
 -> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool)))
-> ClosedTerm ((v :--> PBool) :--> (PMap any k v :--> PBool))
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a b. (a -> b) -> a -> b
$
  (Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap any k v) -> Term s PBool)
-> Term s (c :--> (PMap any k v :--> PBool))
plam ((Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
 -> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool)))
-> (Term s (v :--> PBool) -> Term s (PMap any k v) -> Term s PBool)
-> Term s ((v :--> PBool) :--> (PMap any k v :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (v :--> PBool)
pred Term s (PMap any k v)
m ->
    Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s ((a :--> PBool) :--> (list a :--> PBool))
PPrelude.pany Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBool))
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s PBool) -> Term s (c :--> PBool)
plam (\Term s (PBuiltinPair (PAsData k) (PAsData v))
pair -> Term s (v :--> PBool)
pred Term s (v :--> PBool) -> Term s v -> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData v) -> Term s v) -> Term s (PAsData v) -> Term s v
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
pair) Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap any k v) -> Term s (PInner (PMap any k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap any k v)
m

{- | Look up the given key in a 'PMap', returning the default value if the key is absent.

@since 2.1.1
-}
pfindWithDefault ::
  forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees) (s :: S).
  ( PIsData k
  , PIsData v
  ) =>
  Term s (v :--> k :--> PMap any k v :--> v)
pfindWithDefault :: forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (v :--> (k :--> (PMap any k v :--> v)))
pfindWithDefault = ClosedTerm (v :--> (k :--> (PMap any k v :--> v)))
-> Term s (v :--> (k :--> (PMap any k v :--> v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (v :--> (k :--> (PMap any k v :--> v)))
 -> Term s (v :--> (k :--> (PMap any k v :--> v))))
-> ClosedTerm (v :--> (k :--> (PMap any k v :--> v)))
-> Term s (v :--> (k :--> (PMap any k v :--> v)))
forall a b. (a -> b) -> a -> b
$ (Term s v -> Term s k -> Term s (PMap any k v :--> v))
-> Term s (v :--> (k :--> (PMap any k v :--> v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s k -> Term s (PMap any k v :--> v))
-> Term s (c :--> (k :--> (PMap any k v :--> v)))
plam ((Term s v -> Term s k -> Term s (PMap any k v :--> v))
 -> Term s (v :--> (k :--> (PMap any k v :--> v))))
-> (Term s v -> Term s k -> Term s (PMap any k v :--> v))
-> Term s (v :--> (k :--> (PMap any k v :--> v)))
forall a b. (a -> b) -> a -> b
$ \Term s v
def Term s k
key -> Term
  s
  (PAsData k
   :--> (v :--> ((PAsData v :--> v) :--> (PMap any k v :--> v))))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (r :: S -> Type) (s :: S).
Term
  s
  (PAsData k
   :--> (r :--> ((PAsData v :--> r) :--> (PMap any k v :--> r))))
pfoldAtData Term
  s
  (PAsData k
   :--> (v :--> ((PAsData v :--> v) :--> (PMap any k v :--> v))))
-> Term s (PAsData k)
-> Term s (v :--> ((PAsData v :--> v) :--> (PMap any k v :--> v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k -> Term s (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s k
key Term s (v :--> ((PAsData v :--> v) :--> (PMap any k v :--> v)))
-> Term s v
-> Term s ((PAsData v :--> v) :--> (PMap any k v :--> v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
def Term s ((PAsData v :--> v) :--> (PMap any k v :--> v))
-> Term s (PAsData v :--> v) -> Term s (PMap any k v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PAsData v) -> Term s v) -> Term s (PAsData v :--> v)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s v) -> Term s (c :--> v)
plam Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData

{- | Insert a new key/value pair into the map, overriding the previous if any.

@since 2.1.1
-}
pinsert ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  Term s (k :--> v :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pinsert :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pinsert = ClosedTerm
  (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
  (Term s k
 -> Term s v -> Term s (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s v -> Term s (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (c :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s k
  -> Term s v -> Term s (PMap 'Sorted k v :--> PMap 'Sorted k v))
 -> Term
      s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s k
    -> Term s v -> Term s (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term
     s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$ \Term s k
key Term s v
val ->
    Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
(POrd k, PIsData k) =>
Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap g k v :--> PMap g k v)))
rebuildAtKey Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s (c :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
plam (Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PAsData k)
-> Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k -> Term s (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s k
key Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s v
val) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#) Term s (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term s k -> Term s (PMap 'Sorted k v :--> PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k
key

{- | Delete a key from the map.

@since 2.1.1
-}
pdelete ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  ) =>
  Term s (k :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pdelete :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k) =>
Term s (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pdelete = Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
(POrd k, PIsData k) =>
Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap g k v :--> PMap g k v)))
rebuildAtKey Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s (c :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
plam Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a. a -> a
id

{- | Zip two 'PMap's, using the given potentially non-commutative value merge
 function for key collisions, and different values for the sides.

 @since 2.1.1
-}
pzipWithDefaults ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  (forall (s' :: S). Term s' v) ->
  (forall (s' :: S). Term s' v) ->
  Term
    s
    ( (v :--> v :--> v)
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
    )
pzipWithDefaults :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
(forall (s' :: S). Term s' v)
-> (forall (s' :: S). Term s' v)
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pzipWithDefaults forall (s' :: S). Term s' v
defLeft forall (s' :: S). Term s' v
defRight =
  ClosedTerm
  ((v :--> (v :--> v))
   :--> (PMap 'Sorted k v
         :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> (v :--> v))
    :--> (PMap 'Sorted k v
          :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
    (Term s (v :--> (v :--> v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (c
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (v :--> (v :--> v))
  -> Term
       s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (v :--> (v :--> v))
    -> Term
         s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
      SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler k v s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s)
-> Term s (v :--> (v :--> v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s v
-> Term s v -> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
forall (s :: S) (v :: S -> Type) (k :: S -> Type).
Term s v
-> Term s v -> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
defaultMergeHandlerNonCommutative Term s v
forall (s' :: S). Term s' v
defLeft Term s v
forall (s' :: S). Term s' v
defRight

{- | Build the intersection of two 'PMap's, merging values that share the same key using the
given function.

@since 2.1.1
-}
pintersectionWith ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  Commutativity ->
  Term s ((v :--> v :--> v) :--> PMap 'Sorted k v :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pintersectionWith :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Commutativity
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pintersectionWith Commutativity
commutativity =
  ClosedTerm
  ((v :--> (v :--> v))
   :--> (PMap 'Sorted k v
         :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> (v :--> v))
    :--> (PMap 'Sorted k v
          :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
    (Term s (v :--> (v :--> v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (c
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (v :--> (v :--> v))
  -> Term
       s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> (v :--> v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (v :--> (v :--> v))
    -> Term
         s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> (v :--> v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
      SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler k v s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s)
-> Term s (v :--> (v :--> v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
intersectionMergeHandler Commutativity
commutativity

{- | Build the intersection of two 'PMap's, merging data-encoded values that share the same key using the
given function.

@since 2.1.1
-}
pintersectionWithData ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  ) =>
  Commutativity ->
  Term
    s
    ( (PAsData v :--> PAsData v :--> PAsData v)
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
    )
pintersectionWithData :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k) =>
Commutativity
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pintersectionWithData Commutativity
commutativity =
  ClosedTerm
  ((PAsData v :--> (PAsData v :--> PAsData v))
   :--> (PMap 'Sorted k v
         :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PAsData v :--> (PAsData v :--> PAsData v))
    :--> (PMap 'Sorted k v
          :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((PAsData v :--> (PAsData v :--> PAsData v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
    (Term s (PAsData v :--> (PAsData v :--> PAsData v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     (c
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (PAsData v :--> (PAsData v :--> PAsData v))
  -> Term
       s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((PAsData v :--> (PAsData v :--> PAsData v))
       :--> (PMap 'Sorted k v
             :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (PAsData v :--> (PAsData v :--> PAsData v))
    -> Term
         s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((PAsData v :--> (PAsData v :--> PAsData v))
      :--> (PMap 'Sorted k v
            :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
      SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWithData (SomeMergeHandler (PAsData k) (PAsData v) s
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (PAsData v :--> (PAsData v :--> PAsData v))
    -> SomeMergeHandler (PAsData k) (PAsData v) s)
-> Term s (PAsData v :--> (PAsData v :--> PAsData v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Commutativity
-> Term s (PAsData v :--> (PAsData v :--> PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
intersectionMergeHandler Commutativity
commutativity

{- | Forget the knowledge that keys were sorted.

@since 2.1.1
-}
pforgetSorted ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type) (s :: S).
  Term s (PMap 'Sorted k v) ->
  Term s (PMap g k v)
pforgetSorted :: forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PMap 'Sorted k v) -> Term s (PMap g k v)
pforgetSorted Term s (PMap 'Sorted k v)
v = Term s (PInner (PMap g k v)) -> Term s (PMap g k v)
forall (s :: S) (a :: S -> Type). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
v)

{- | Gives 'PTrue' if both argument 'PMap's contain mappings for exactly the
 same set of keys. Requires a number of equality comparisons between keys
 proportional to the length of the shorter argument.

 @since 2.1.1
-}
pkeysEqual ::
  forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  ( PEq k
  , PIsData k
  ) =>
  Term s (PMap 'Sorted k a :--> PMap 'Sorted k b :--> PBool)
pkeysEqual :: forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
(PEq k, PIsData k) =>
Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
pkeysEqual = ClosedTerm (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
-> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
 -> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool)))
-> ClosedTerm (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
-> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
forall a b. (a -> b) -> a -> b
$
  (Term s (PMap 'Sorted k a)
 -> Term s (PMap 'Sorted k b) -> Term s PBool)
-> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k b) -> Term s PBool)
-> Term s (c :--> (PMap 'Sorted k b :--> PBool))
plam ((Term s (PMap 'Sorted k a)
  -> Term s (PMap 'Sorted k b) -> Term s PBool)
 -> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool)))
-> (Term s (PMap 'Sorted k a)
    -> Term s (PMap 'Sorted k b) -> Term s PBool)
-> Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap 'Sorted k a)
kvs Term s (PMap 'Sorted k b)
kvs' ->
    Term s (PMap 'Sorted k a)
-> (PMap 'Sorted k a s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Sorted k a)
kvs ((PMap 'Sorted k a s -> Term s PBool) -> Term s PBool)
-> (PMap 'Sorted k a s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell) ->
      Term s (PMap 'Sorted k b)
-> (PMap 'Sorted k b s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Sorted k b)
kvs' ((PMap 'Sorted k b s -> Term s PBool) -> Term s PBool)
-> (PMap 'Sorted k b s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ->
        Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
forall (s' :: S).
Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
go Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell'
  where
    go ::
      forall (s' :: S).
      Term
        s'
        ( PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool
        )
    go :: forall (s' :: S).
Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
go = (forall (s' :: S).
 Term
   s'
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
          :--> PBool)))
-> Term
     s'
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s' :: S).
  Term
    s'
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
           :--> PBool)))
 -> Term
      s'
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool)))
-> (forall (s' :: S).
    Term
      s'
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool)))
-> Term
     s'
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall a b. (a -> b) -> a -> b
$
      Term
  s
  (((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
           :--> PBool))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                :--> PBool)))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
           :--> PBool))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                :--> PBool)))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
          :--> PBool))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s PBool)
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s PBool)
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
plam ((Term
    s
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
           :--> PBool))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
  -> Term s PBool)
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
              :--> PBool))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                   :--> PBool))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s PBool)
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
             :--> PBool))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
self Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell' ->
        Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData a))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData a))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData a))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData a))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData a))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell) ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData a))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData a))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
          PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
  s
PNothing -> Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData b))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData b))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData b))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
            PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
  s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PTrue -- no mismatches found
            PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
_ -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse -- one argument too long
          PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
kv -> Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData b))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData b))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData b))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
            PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
  s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse -- one argument too long
            PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
kv' -> Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData a))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
kv ((PPair
    (PBuiltinPair (PAsData k) (PAsData a))
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData a))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PPair Term s (PBuiltinPair (PAsData k) (PAsData a))
h Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
t) ->
              Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
kv' ((PPair
    (PBuiltinPair (PAsData k) (PAsData b))
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PPair Term s (PBuiltinPair (PAsData k) (PAsData b))
h' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t') ->
                Term s PBool -> Term s PBool -> Term s PBool -> Term s PBool
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                  ((Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData a)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData a))
h) Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== (Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData b)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData b))
h'))
                  (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
t Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t') -- continue
                  (PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse) -- key mismatch

{- | As 'pkeysEqual', but requires only 'PEq' constraints for the keys, and
 works for 'Unsorted' 'PMap's. This requires a number of equality comparisons
 between keys proportional to the product of the lengths of both arguments:
 that is, this function is quadratic.

 @since 2.1.1
-}
pkeysEqualUnsorted ::
  forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
  ( PIsData k
  , PIsData a
  , PIsData b
  ) =>
  Term s (PMap 'Unsorted k a :--> PMap 'Unsorted k b :--> PBool)
pkeysEqualUnsorted :: forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type) (s :: S).
(PIsData k, PIsData a, PIsData b) =>
Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
pkeysEqualUnsorted = ClosedTerm
  (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
-> Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
 -> Term
      s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool)))
-> ClosedTerm
     (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
-> Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
forall a b. (a -> b) -> a -> b
$
  (Term s (PMap 'Unsorted k a)
 -> Term s (PMap 'Unsorted k b) -> Term s PBool)
-> Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Unsorted k b) -> Term s PBool)
-> Term s (c :--> (PMap 'Unsorted k b :--> PBool))
plam ((Term s (PMap 'Unsorted k a)
  -> Term s (PMap 'Unsorted k b) -> Term s PBool)
 -> Term
      s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool)))
-> (Term s (PMap 'Unsorted k a)
    -> Term s (PMap 'Unsorted k b) -> Term s PBool)
-> Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap 'Unsorted k a)
kvs Term s (PMap 'Unsorted k b)
kvs' ->
    Term s (PMap 'Unsorted k a)
-> (PMap 'Unsorted k a s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Unsorted k a)
kvs ((PMap 'Unsorted k a s -> Term s PBool) -> Term s PBool)
-> (PMap 'Unsorted k a s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell) ->
      Term s (PMap 'Unsorted k b)
-> (PMap 'Unsorted k b s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Unsorted k b)
kvs' ((PMap 'Unsorted k b s -> Term s PBool) -> Term s PBool)
-> (PMap 'Unsorted k b s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ->
        Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
forall (s' :: S).
Term
  s'
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
go Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
-> Term s (PMap 'Unsorted k a)
-> Term
     s
     (PMap 'Unsorted k b
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs Term
  s
  (PMap 'Unsorted k b
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
-> Term s (PMap 'Unsorted k b)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell'
  where
    go ::
      forall (s' :: S).
      Term
        s'
        ( PMap 'Unsorted k a
            :--> PMap 'Unsorted k b
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool
        )
    go :: forall (s' :: S).
Term
  s'
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
go = (forall (s' :: S).
 Term
   s'
   (PMap 'Unsorted k a
    :--> (PMap 'Unsorted k b
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                      :--> PBool)))))
-> Term
     s'
     (PMap 'Unsorted k a
      :--> (PMap 'Unsorted k b
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                        :--> PBool))))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s' :: S).
  Term
    s'
    (PMap 'Unsorted k a
     :--> (PMap 'Unsorted k b
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                       :--> PBool)))))
 -> Term
      s'
      (PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool)))))
-> (forall (s' :: S).
    Term
      s'
      (PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool)))))
-> Term
     s'
     (PMap 'Unsorted k a
      :--> (PMap 'Unsorted k b
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                        :--> PBool))))
forall a b. (a -> b) -> a -> b
$
      Term
  s
  (((PMap 'Unsorted k a
     :--> (PMap 'Unsorted k b
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                       :--> PBool))))
    :--> (PMap 'Unsorted k a
          :--> (PMap 'Unsorted k b
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                            :--> PBool)))))
   :--> (PMap 'Unsorted k a
         :--> (PMap 'Unsorted k b
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                           :--> PBool)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PMap 'Unsorted k a
     :--> (PMap 'Unsorted k b
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                       :--> PBool))))
    :--> (PMap 'Unsorted k a
          :--> (PMap 'Unsorted k b
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                            :--> PBool)))))
   :--> (PMap 'Unsorted k a
         :--> (PMap 'Unsorted k b
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                           :--> PBool)))))
-> Term
     s
     ((PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool))))
      :--> (PMap 'Unsorted k a
            :--> (PMap 'Unsorted k b
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                              :--> PBool)))))
-> Term
     s
     (PMap 'Unsorted k a
      :--> (PMap 'Unsorted k b
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                        :--> PBool))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PMap 'Unsorted k a
    :--> (PMap 'Unsorted k b
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                      :--> PBool))))
 -> Term s (PMap 'Unsorted k a)
 -> Term s (PMap 'Unsorted k b)
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s PBool)
-> Term
     s
     ((PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool))))
      :--> (PMap 'Unsorted k a
            :--> (PMap 'Unsorted k b
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                              :--> PBool)))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PMap 'Unsorted k a)
 -> Term s (PMap 'Unsorted k b)
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
 -> Term s PBool)
-> Term
     s
     (c
      :--> (PMap 'Unsorted k a
            :--> (PMap 'Unsorted k b
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                              :--> PBool)))))
plam ((Term
    s
    (PMap 'Unsorted k a
     :--> (PMap 'Unsorted k b
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                       :--> PBool))))
  -> Term s (PMap 'Unsorted k a)
  -> Term s (PMap 'Unsorted k b)
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
  -> Term s PBool)
 -> Term
      s
      ((PMap 'Unsorted k a
        :--> (PMap 'Unsorted k b
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                          :--> PBool))))
       :--> (PMap 'Unsorted k a
             :--> (PMap 'Unsorted k b
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                               :--> PBool))))))
-> (Term
      s
      (PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool))))
    -> Term s (PMap 'Unsorted k a)
    -> Term s (PMap 'Unsorted k b)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    -> Term s PBool)
-> Term
     s
     ((PMap 'Unsorted k a
       :--> (PMap 'Unsorted k b
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                         :--> PBool))))
      :--> (PMap 'Unsorted k a
            :--> (PMap 'Unsorted k b
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                              :--> PBool)))))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
self Term s (PMap 'Unsorted k a)
kvs Term s (PMap 'Unsorted k b)
kvs' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell' ->
        Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData a))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData a))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData a))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData a))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData a))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell) ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData a))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData a))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
          PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
  s
PNothing -> Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData b))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData b))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData b))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
            -- We reached the end, so we match
            PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
  s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PTrue
            PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
ht' -> Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
ht' ((PPair
    (PBuiltinPair (PAsData k) (PAsData b))
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PPair Term s (PBuiltinPair (PAsData k) (PAsData b))
h' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t') ->
              Term s (PMaybe a) -> (PMaybe a s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (k :--> (PMap 'Unsorted k a :--> PMaybe a))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap any k v :--> PMaybe v))
plookup Term s (k :--> (PMap 'Unsorted k a :--> PMaybe a))
-> Term s k -> Term s (PMap 'Unsorted k a :--> PMaybe a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData b)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData b))
h') Term s (PMap 'Unsorted k a :--> PMaybe a)
-> Term s (PMap 'Unsorted k a) -> Term s (PMaybe a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs) ((PMaybe a s -> Term s PBool) -> Term s PBool)
-> (PMaybe a s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
                -- We mismatch, so fail
                PMaybe a s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse
                -- We match, so continue
                PJust Term s a
_ -> Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
self Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
-> Term s (PMap 'Unsorted k a)
-> Term
     s
     (PMap 'Unsorted k b
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs Term
  s
  (PMap 'Unsorted k b
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
-> Term s (PMap 'Unsorted k b)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
ell Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t'
          PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
ht -> Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData a))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData a))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))))
ht ((PPair
    (PBuiltinPair (PAsData k) (PAsData a))
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData a))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PPair Term s (PBuiltinPair (PAsData k) (PAsData a))
h Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
t) ->
            Term
  s
  (PMaybe
     (PPair
        (PBuiltinPair (PAsData k) (PAsData b))
        (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
PIsListLike list a =>
Term s (list a :--> PMaybe (PPair a (list a)))
PPrelude.puncons Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
   :--> PMaybe
          (PPair
             (PBuiltinPair (PAsData k) (PAsData b))
             (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term
     s
     (PMaybe
        (PPair
           (PBuiltinPair (PAsData k) (PAsData b))
           (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell') ((PMaybe
    (PPair
       (PBuiltinPair (PAsData k) (PAsData b))
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PMaybe
      (PPair
         (PBuiltinPair (PAsData k) (PAsData b))
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
              PMaybe
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
  s
PNothing -> Term s (PMaybe b) -> (PMaybe b s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (k :--> (PMap 'Unsorted k b :--> PMaybe b))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap any k v :--> PMaybe v))
plookup Term s (k :--> (PMap 'Unsorted k b :--> PMaybe b))
-> Term s k -> Term s (PMap 'Unsorted k b :--> PMaybe b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData a)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData a))
h) Term s (PMap 'Unsorted k b :--> PMaybe b)
-> Term s (PMap 'Unsorted k b) -> Term s (PMaybe b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs') ((PMaybe b s -> Term s PBool) -> Term s PBool)
-> (PMaybe b s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
                -- We mismatch, so fail
                PMaybe b s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse
                -- We match, so continue
                PJust Term s b
_ -> Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
self Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
-> Term s (PMap 'Unsorted k a)
-> Term
     s
     (PMap 'Unsorted k b
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs Term
  s
  (PMap 'Unsorted k b
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
-> Term s (PMap 'Unsorted k b)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
t Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
ell'
              -- To save some effort, we try both matches in one shot
              PJust Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
ht' -> Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term
  s
  (PPair
     (PBuiltinPair (PAsData k) (PAsData b))
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))))
ht' ((PPair
    (PBuiltinPair (PAsData k) (PAsData b))
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
    s
  -> Term s PBool)
 -> Term s PBool)
-> (PPair
      (PBuiltinPair (PAsData k) (PAsData b))
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
      s
    -> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ \(PPair Term s (PBuiltinPair (PAsData k) (PAsData b))
h' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t') ->
                Term s (PMaybe b) -> (PMaybe b s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (k :--> (PMap 'Unsorted k b :--> PMaybe b))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap any k v :--> PMaybe v))
plookup Term s (k :--> (PMap 'Unsorted k b :--> PMaybe b))
-> Term s k -> Term s (PMap 'Unsorted k b :--> PMaybe b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData a) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData a)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData a))
h) Term s (PMap 'Unsorted k b :--> PMaybe b)
-> Term s (PMap 'Unsorted k b) -> Term s (PMaybe b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs') ((PMaybe b s -> Term s PBool) -> Term s PBool)
-> (PMaybe b s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
                  -- We mismatch, so fail
                  PMaybe b s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse
                  -- Try the other direction
                  PJust Term s b
_ -> Term s (PMaybe a) -> (PMaybe a s -> Term s PBool) -> Term s PBool
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (k :--> (PMap 'Unsorted k a :--> PMaybe a))
forall (k :: S -> Type) (v :: S -> Type) (any :: KeyGuarantees)
       (s :: S).
(PIsData k, PIsData v) =>
Term s (k :--> (PMap any k v :--> PMaybe v))
plookup Term s (k :--> (PMap 'Unsorted k a :--> PMaybe a))
-> Term s k -> Term s (PMap 'Unsorted k a :--> PMaybe a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData b) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData b)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData b))
h') Term s (PMap 'Unsorted k a :--> PMaybe a)
-> Term s (PMap 'Unsorted k a) -> Term s (PMaybe a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs) ((PMaybe a s -> Term s PBool) -> Term s PBool)
-> (PMaybe a s -> Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ \case
                    -- We mismatch, so fail
                    PMaybe a s
PNothing -> PBool s -> Term s PBool
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBool s
forall (s :: S). PBool s
PFalse
                    -- Both succeeded, so continue on tails
                    PJust Term s a
_ -> Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
self Term
  s
  (PMap 'Unsorted k a
   :--> (PMap 'Unsorted k b
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                     :--> PBool))))
-> Term s (PMap 'Unsorted k a)
-> Term
     s
     (PMap 'Unsorted k b
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
                  :--> PBool)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k a)
kvs Term
  s
  (PMap 'Unsorted k b
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
               :--> PBool)))
-> Term s (PMap 'Unsorted k b)
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
            :--> PBool))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k b)
kvs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b))
         :--> PBool))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData a)))
t Term
  s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
-> Term s PBool
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData b)))
t'

{- | Get the key of a key-value pair.

@since 2.1.1
-}
pkvPairKey ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  PIsData k =>
  Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey = ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> k)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k))
-> ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall a b. (a -> b) -> a -> b
$ (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s k) -> Term s (c :--> k)
plam ((Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData k) (PAsData v))
kv -> Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv)

{- | Get the value of a key-value pair.

@since 2.1.1
-}
pkvPairValue ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  PIsData v =>
  Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
pkvPairValue :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData v =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
pkvPairValue = ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> v)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v))
-> ClosedTerm (PBuiltinPair (PAsData k) (PAsData v) :--> v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
forall a b. (a -> b) -> a -> b
$ (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s v) -> Term s (c :--> v)
plam ((Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s v)
 -> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData k) (PAsData v))
kv -> Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv)

-- | @since 2.1.1
punsortedMapFromFoldable ::
  forall (k :: S -> Type) (v :: S -> Type) (f :: Type -> Type) (s :: S).
  ( Foldable f
  , PIsData k
  , PIsData v
  ) =>
  f (Term s k, Term s v) ->
  Term s (PMap 'Unsorted k v)
punsortedMapFromFoldable :: forall (k :: S -> Type) (v :: S -> Type) (f :: Type -> Type)
       (s :: S).
(Foldable f, PIsData k, PIsData v) =>
f (Term s k, Term s v) -> Term s (PMap 'Unsorted k v)
punsortedMapFromFoldable = PMap 'Unsorted k v s -> Term s (PMap 'Unsorted k v)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Unsorted k v s -> Term s (PMap 'Unsorted k v))
-> (f (Term s k, Term s v) -> PMap 'Unsorted k v s)
-> f (Term s k, Term s v)
-> Term s (PMap 'Unsorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Unsorted k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> PMap 'Unsorted k v s)
-> (f (Term s k, Term s v)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> f (Term s k, Term s v)
-> PMap 'Unsorted k v s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> (Term s k, Term s v)
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> f (Term s k, Term s v)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall b a. (b -> a -> b) -> b -> f a -> b
forall (t :: Type -> Type) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (Term s k, Term s v)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s' :: S).
Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (Term s' k, Term s' v)
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
go (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
forall (a :: S -> Type) (s :: S). PBuiltinList a s
PNil)
  where
    go ::
      forall (s' :: S).
      Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))) ->
      (Term s' k, Term s' v) ->
      Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    go :: forall (s' :: S).
Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (Term s' k, Term s' v)
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
go Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
acc (Term s' k
key, Term s' v
val) =
      PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s'
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s'
 -> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s')
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s' (PBuiltinPair (PAsData k) (PAsData v))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s'
forall (a :: S -> Type) (s :: S).
Term s a -> Term s (PBuiltinList a) -> PBuiltinList a s
PCons (Term
  s'
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin Term
  s'
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (PAsData k)
-> Term s' (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' k -> Term s' (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s' k
key Term s' (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
-> Term s' (PAsData v)
-> Term s' (PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' v -> Term s' (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s' v
val) (Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
acc

-- | @since 2.1.1
psortedMapFromFoldable ::
  forall (k :: S -> Type) (v :: S -> Type) (f :: Type -> Type) (s :: S).
  ( Foldable f
  , POrd k
  , PIsData k
  , PIsData v
  ) =>
  f (Term s k, Term s v) ->
  Term s (PMap 'Sorted k v)
psortedMapFromFoldable :: forall (k :: S -> Type) (v :: S -> Type) (f :: Type -> Type)
       (s :: S).
(Foldable f, POrd k, PIsData k, PIsData v) =>
f (Term s k, Term s v) -> Term s (PMap 'Sorted k v)
psortedMapFromFoldable = (Term s (PMap 'Sorted k v)
 -> (Term s k, Term s v) -> Term s (PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
-> f (Term s k, Term s v)
-> Term s (PMap 'Sorted k v)
forall b a. (b -> a -> b) -> b -> f a -> b
forall (t :: Type -> Type) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' Term s (PMap 'Sorted k v)
-> (Term s k, Term s v) -> Term s (PMap 'Sorted k v)
forall (s' :: S).
Term s' (PMap 'Sorted k v)
-> (Term s' k, Term s' v) -> Term s' (PMap 'Sorted k v)
go Term s (PMap 'Sorted k v)
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Term s (PMap 'Sorted k v)
pempty
  where
    go ::
      forall (s' :: S).
      Term s' (PMap 'Sorted k v) ->
      (Term s' k, Term s' v) ->
      Term s' (PMap 'Sorted k v)
    go :: forall (s' :: S).
Term s' (PMap 'Sorted k v)
-> (Term s' k, Term s' v) -> Term s' (PMap 'Sorted k v)
go Term s' (PMap 'Sorted k v)
acc (Term s' k
key, Term s' v
val) = Term s' (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(POrd k, PIsData k, PIsData v) =>
Term s (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pinsert Term s' (k :--> (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term s' k
-> Term s' (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' k
key Term s' (v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
-> Term s' v -> Term s' (PMap 'Sorted k v :--> PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' v
val Term s' (PMap 'Sorted k v :--> PMap 'Sorted k v)
-> Term s' (PMap 'Sorted k v) -> Term s' (PMap 'Sorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' (PMap 'Sorted k v)
acc

{- | Given an \'updater\' and a key, if the key exists in the 'PMap', apply the
 \'updater\' to it, otherwise do nothing. If the \'updater\' produces
 'PNothing', the value is deleted; otherwise, it is modified to the result.

 Performance will be equivalent to a lookup followed by an insert (or delete),
 as well as the cost of calling the \'updater\'.

 @since 2.1.1
-}
pupdate ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , PIsData v
  , POrd k
  ) =>
  Term s ((v :--> PMaybe v) :--> k :--> PMap 'Sorted k v :--> PMap 'Sorted k v)
pupdate :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PIsData v, POrd k) =>
Term
  s
  ((v :--> PMaybe v)
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
pupdate = ClosedTerm
  ((v :--> PMaybe v)
   :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> PMaybe v)
      :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> PMaybe v)
    :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
 -> Term
      s
      ((v :--> PMaybe v)
       :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> ClosedTerm
     ((v :--> PMaybe v)
      :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> Term
     s
     ((v :--> PMaybe v)
      :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$
  (Term s (v :--> PMaybe v)
 -> Term s k
 -> Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v))
-> Term
     s
     ((v :--> PMaybe v)
      :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s k
 -> Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v))
-> Term
     s (c :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
plam ((Term s (v :--> PMaybe v)
  -> Term s k
  -> Term s (PMap 'Sorted k v)
  -> Term s (PMap 'Sorted k v))
 -> Term
      s
      ((v :--> PMaybe v)
       :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))))
-> (Term s (v :--> PMaybe v)
    -> Term s k
    -> Term s (PMap 'Sorted k v)
    -> Term s (PMap 'Sorted k v))
-> Term
     s
     ((v :--> PMaybe v)
      :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
forall a b. (a -> b) -> a -> b
$ \Term s (v :--> PMaybe v)
updater Term s k
key Term s (PMap 'Sorted k v)
kvs -> Term s (PMap 'Sorted k v)
-> (PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Sorted k v)
kvs ((PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
 -> Term s (PMap 'Sorted k v))
-> (PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
-> Term s (PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
kvs') ->
    PMap 'Sorted k v s -> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> PMap 'Sorted k v s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PMap 'Sorted k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Sorted k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PMap 'Sorted k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$
      ( (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
          ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
              Term s k
-> (Term s k
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData k) -> Term s k) -> Term s (PAsData k) -> Term s k
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x) ((Term s k
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (Term s k
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \Term s k
k ->
                Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                  (Term s k
k Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s k
key)
                  ( Term s (PMaybe v)
-> (PMaybe v s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (v :--> PMaybe v)
updater Term s (v :--> PMaybe v) -> Term s v -> Term s (PMaybe v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x)) ((PMaybe v s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PMaybe v s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \case
                      PMaybe v s
PNothing -> Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs
                      PJust Term s v
v -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term
  s
  (PAsData a
   :--> (PAsData b :--> PBuiltinPair (PAsData a) (PAsData b)))
ppairDataBuiltin Term
  s
  (PAsData k
   :--> (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PAsData k)
-> Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k -> Term s (PAsData k)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s k
k Term s (PAsData v :--> PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata Term s v
v) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs
                  )
                  (Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s k
key Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#<= Term s k
k) (Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs) (Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs))
          )
          (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. a -> b -> a
const Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil)
          # kvs'
      )

{- | If a value exists at the specified key, apply the function argument to it;
 otherwise, do nothing.

 @since 2.1.1
-}
padjust ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , PEq k
  , PIsData v
  ) =>
  Term s ((v :--> v) :--> k :--> PMap 'Unsorted k v :--> PMap 'Unsorted k v)
padjust :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PEq k, PIsData v) =>
Term
  s
  ((v :--> v)
   :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
padjust = ClosedTerm
  ((v :--> v)
   :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
-> Term
     s
     ((v :--> v)
      :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((v :--> v)
    :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
 -> Term
      s
      ((v :--> v)
       :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v))))
-> ClosedTerm
     ((v :--> v)
      :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
-> Term
     s
     ((v :--> v)
      :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
forall a b. (a -> b) -> a -> b
$
  (Term s (v :--> v)
 -> Term s k
 -> Term s (PMap 'Unsorted k v)
 -> Term s (PMap 'Unsorted k v))
-> Term
     s
     ((v :--> v)
      :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s k
 -> Term s (PMap 'Unsorted k v)
 -> Term s (PMap 'Unsorted k v))
-> Term
     s (c :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
plam ((Term s (v :--> v)
  -> Term s k
  -> Term s (PMap 'Unsorted k v)
  -> Term s (PMap 'Unsorted k v))
 -> Term
      s
      ((v :--> v)
       :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v))))
-> (Term s (v :--> v)
    -> Term s k
    -> Term s (PMap 'Unsorted k v)
    -> Term s (PMap 'Unsorted k v))
-> Term
     s
     ((v :--> v)
      :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
forall a b. (a -> b) -> a -> b
$ \Term s (v :--> v)
f Term s k
key Term s (PMap 'Unsorted k v)
kvs ->
    Term
  s
  ((k :--> (v :--> v))
   :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v))
forall (k :: S -> Type) (a :: S -> Type) (b :: S -> Type)
       (keysort :: KeyGuarantees) (s :: S).
(PIsData k, PIsData a, PIsData b) =>
Term
  s
  ((k :--> (a :--> b))
   :--> (PMap keysort k a :--> PMap 'Unsorted k b))
pmapWithKey Term
  s
  ((k :--> (v :--> v))
   :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v))
-> Term s (k :--> (v :--> v))
-> Term s (PMap 'Unsorted k v :--> PMap 'Unsorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s k -> Term s v -> Term s v) -> Term s (k :--> (v :--> v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s v -> Term s v) -> Term s (c :--> (v :--> v))
plam (\Term s k
k' Term s v
a -> Term s PBool -> Term s v -> Term s v -> Term s v
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s k
k' Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s k
key) (Term s (v :--> v)
f Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
a) Term s v
a) Term s (PMap 'Unsorted k v :--> PMap 'Unsorted k v)
-> Term s (PMap 'Unsorted k v) -> Term s (PMap 'Unsorted k v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted k v)
kvs

{- | Left-associative fold of a 'PMap' with keys. Keys and values will be
 presented in key order.

 @since 2.1.1
-}
pfoldlWithKey ::
  forall (a :: S -> Type) (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , PIsData v
  ) =>
  Term s ((a :--> k :--> v :--> a) :--> a :--> PMap 'Sorted k v :--> a)
pfoldlWithKey :: forall (a :: S -> Type) (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PIsData v) =>
Term
  s
  ((a :--> (k :--> (v :--> a)))
   :--> (a :--> (PMap 'Sorted k v :--> a)))
pfoldlWithKey = ClosedTerm
  ((a :--> (k :--> (v :--> a)))
   :--> (a :--> (PMap 'Sorted k v :--> a)))
-> Term
     s
     ((a :--> (k :--> (v :--> a)))
      :--> (a :--> (PMap 'Sorted k v :--> a)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((a :--> (k :--> (v :--> a)))
    :--> (a :--> (PMap 'Sorted k v :--> a)))
 -> Term
      s
      ((a :--> (k :--> (v :--> a)))
       :--> (a :--> (PMap 'Sorted k v :--> a))))
-> ClosedTerm
     ((a :--> (k :--> (v :--> a)))
      :--> (a :--> (PMap 'Sorted k v :--> a)))
-> Term
     s
     ((a :--> (k :--> (v :--> a)))
      :--> (a :--> (PMap 'Sorted k v :--> a)))
forall a b. (a -> b) -> a -> b
$
  (Term s (a :--> (k :--> (v :--> a)))
 -> Term s a -> Term s (PMap 'Sorted k v) -> Term s a)
-> Term
     s
     ((a :--> (k :--> (v :--> a)))
      :--> (a :--> (PMap 'Sorted k v :--> a)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s a -> Term s (PMap 'Sorted k v) -> Term s a)
-> Term s (c :--> (a :--> (PMap 'Sorted k v :--> a)))
plam ((Term s (a :--> (k :--> (v :--> a)))
  -> Term s a -> Term s (PMap 'Sorted k v) -> Term s a)
 -> Term
      s
      ((a :--> (k :--> (v :--> a)))
       :--> (a :--> (PMap 'Sorted k v :--> a))))
-> (Term s (a :--> (k :--> (v :--> a)))
    -> Term s a -> Term s (PMap 'Sorted k v) -> Term s a)
-> Term
     s
     ((a :--> (k :--> (v :--> a)))
      :--> (a :--> (PMap 'Sorted k v :--> a)))
forall a b. (a -> b) -> a -> b
$ \Term s (a :--> (k :--> (v :--> a)))
f Term s a
x Term s (PMap 'Sorted k v)
kvs -> Term s (PMap 'Sorted k v)
-> (PMap 'Sorted k v s -> Term s a) -> Term s a
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap 'Sorted k v)
kvs ((PMap 'Sorted k v s -> Term s a) -> Term s a)
-> (PMap 'Sorted k v s -> Term s a) -> Term s a
forall a b. (a -> b) -> a -> b
$ \case
    PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
kvs' ->
      Term
  s
  ((a :--> (PBuiltinPair (PAsData k) (PAsData v) :--> a))
   :--> (a
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a)))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (b :: S -> Type).
PIsListLike list a =>
Term s ((b :--> (a :--> b)) :--> (b :--> (list a :--> b)))
pfoldl Term
  s
  ((a :--> (PBuiltinPair (PAsData k) (PAsData v) :--> a))
   :--> (a
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a)))
-> Term s (a :--> (PBuiltinPair (PAsData k) (PAsData v) :--> a))
-> Term
     s
     (a
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s a
 -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s a)
-> Term s (a :--> (PBuiltinPair (PAsData k) (PAsData v) :--> a))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s a)
-> Term s (c :--> (PBuiltinPair (PAsData k) (PAsData v) :--> a))
plam (\Term s a
acc Term s (PBuiltinPair (PAsData k) (PAsData v))
kv -> Term s (a :--> (k :--> (v :--> a)))
f Term s (a :--> (k :--> (v :--> a)))
-> Term s a -> Term s (k :--> (v :--> a))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
acc Term s (k :--> (v :--> a)) -> Term s k -> Term s (v :--> a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv) Term s (v :--> a) -> Term s v -> Term s a
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData v =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
pkvPairValue Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
-> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv)) Term
  s
  (a
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a))
-> Term s a
-> Term
     s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> a)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s a
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
kvs'

{- | Project all key-value pairs into a 'Monoid', then combine. Keys and values
 will be presented in key order.

 @since 2.1.1
-}
pfoldMapWithKey ::
  forall (m :: S -> Type) (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( PIsData k
  , PIsData v
  , forall (s' :: S). Monoid (Term s' m)
  ) =>
  Term s ((k :--> v :--> m) :--> PMap 'Sorted k v :--> m)
pfoldMapWithKey :: forall (m :: S -> Type) (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PIsData v, forall (s' :: S). Monoid (Term s' m)) =>
Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
pfoldMapWithKey = ClosedTerm ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
-> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
 -> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m)))
-> ClosedTerm ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
-> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
forall a b. (a -> b) -> a -> b
$
  (Term s (k :--> (v :--> m))
 -> Term s (PMap 'Sorted k v) -> Term s m)
-> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMap 'Sorted k v) -> Term s m)
-> Term s (c :--> (PMap 'Sorted k v :--> m))
plam ((Term s (k :--> (v :--> m))
  -> Term s (PMap 'Sorted k v) -> Term s m)
 -> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m)))
-> (Term s (k :--> (v :--> m))
    -> Term s (PMap 'Sorted k v) -> Term s m)
-> Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
forall a b. (a -> b) -> a -> b
$ \Term s (k :--> (v :--> m))
f Term s (PMap 'Sorted k v)
kvs ->
    Term
  s
  ((m :--> (k :--> (v :--> m)))
   :--> (m :--> (PMap 'Sorted k v :--> m)))
forall (a :: S -> Type) (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, PIsData v) =>
Term
  s
  ((a :--> (k :--> (v :--> a)))
   :--> (a :--> (PMap 'Sorted k v :--> a)))
pfoldlWithKey Term
  s
  ((m :--> (k :--> (v :--> m)))
   :--> (m :--> (PMap 'Sorted k v :--> m)))
-> Term s (m :--> (k :--> (v :--> m)))
-> Term s (m :--> (PMap 'Sorted k v :--> m))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s m -> Term s k -> Term s v -> Term s m)
-> Term s (m :--> (k :--> (v :--> m)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s k -> Term s v -> Term s m)
-> Term s (c :--> (k :--> (v :--> m)))
plam (\Term s m
acc Term s k
k Term s v
v -> Term s m
acc Term s m -> Term s m -> Term s m
forall a. Semigroup a => a -> a -> a
<> (Term s (k :--> (v :--> m))
f Term s (k :--> (v :--> m)) -> Term s k -> Term s (v :--> m)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s k
k Term s (v :--> m) -> Term s v -> Term s m
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
v)) Term s (m :--> (PMap 'Sorted k v :--> m))
-> Term s m -> Term s (PMap 'Sorted k v :--> m)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s m
forall a. Monoid a => a
mempty Term s (PMap 'Sorted k v :--> m)
-> Term s (PMap 'Sorted k v) -> Term s m
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v)
kvs

{- | Get a list-like structure full of the keys of the argument 'PMap'. If the
 'PMap' is 'Sorted', the keys will maintain that order, and will be unique;
 otherwise, the order is unspecified, and duplicates may exist.

 = Note

 You will need to specify what manner of list-like structure you want; we have
 arranged the type signature to make specifying this easy with
 @TypeApplications@.

 @since 2.1.1
-}
pkeys ::
  forall
    (ell :: (S -> Type) -> S -> Type)
    (k :: S -> Type)
    (v :: S -> Type)
    (keys :: KeyGuarantees)
    (s :: S).
  ( PListLike ell
  , PElemConstraint ell (PAsData k)
  ) =>
  Term s (PMap keys k v :--> ell (PAsData k))
pkeys :: forall (ell :: (S -> Type) -> S -> Type) (k :: S -> Type)
       (v :: S -> Type) (keys :: KeyGuarantees) (s :: S).
(PListLike ell, PElemConstraint ell (PAsData k)) =>
Term s (PMap keys k v :--> ell (PAsData k))
pkeys = ClosedTerm (PMap keys k v :--> ell (PAsData k))
-> Term s (PMap keys k v :--> ell (PAsData k))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PMap keys k v :--> ell (PAsData k))
 -> Term s (PMap keys k v :--> ell (PAsData k)))
-> ClosedTerm (PMap keys k v :--> ell (PAsData k))
-> Term s (PMap keys k v :--> ell (PAsData k))
forall a b. (a -> b) -> a -> b
$
  (Term s (PMap keys k v) -> Term s (ell (PAsData k)))
-> Term s (PMap keys k v :--> ell (PAsData k))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (ell (PAsData k)))
-> Term s (c :--> ell (PAsData k))
plam ((Term s (PMap keys k v) -> Term s (ell (PAsData k)))
 -> Term s (PMap keys k v :--> ell (PAsData k)))
-> (Term s (PMap keys k v) -> Term s (ell (PAsData k)))
-> Term s (PMap keys k v :--> ell (PAsData k))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap keys k v)
kvs -> Term s (PMap keys k v)
-> (PMap keys k v s -> Term s (ell (PAsData k)))
-> Term s (ell (PAsData k))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMap keys k v)
kvs ((PMap keys k v s -> Term s (ell (PAsData k)))
 -> Term s (ell (PAsData k)))
-> (PMap keys k v s -> Term s (ell (PAsData k)))
-> Term s (ell (PAsData k))
forall a b. (a -> b) -> a -> b
$ \(PMap Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
kvs') ->
    (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> ell (PAsData k))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (ell (PAsData k)))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ell (PAsData k))
    -> Term s (ell (PAsData k)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ell (PAsData k))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (ell (PAsData k))
forall (s' :: S).
Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
-> Term s' (PBuiltinPair (PAsData k) (PAsData v))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (ell (PAsData k))
go (Term s (ell (PAsData k))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ell (PAsData k))
-> Term s (ell (PAsData k))
forall a b. a -> b -> a
const Term s (ell (PAsData k))
forall (a :: S -> Type) (s :: S).
PElemConstraint ell a =>
Term s (ell a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (ell (PAsData k))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
kvs'
  where
    go ::
      forall (s' :: S).
      Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) :--> ell (PAsData k)) ->
      Term s' (PBuiltinPair (PAsData k) (PAsData v)) ->
      Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))) ->
      Term s' (ell (PAsData k))
    go :: forall (s' :: S).
Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
-> Term s' (PBuiltinPair (PAsData k) (PAsData v))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (ell (PAsData k))
go Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
self Term s' (PBuiltinPair (PAsData k) (PAsData v))
kv Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
acc = Term s' (PAsData k :--> (ell (PAsData k) :--> ell (PAsData k)))
forall (a :: S -> Type) (s :: S).
PElemConstraint ell a =>
Term s (a :--> (ell a :--> ell a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term s' (PAsData k :--> (ell (PAsData k) :--> ell (PAsData k)))
-> Term s' (PAsData k)
-> Term s' (ell (PAsData k) :--> ell (PAsData k))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s' (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s' (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s' (PBuiltinPair (PAsData k) (PAsData v))
-> Term s' (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' (PBuiltinPair (PAsData k) (PAsData v))
kv) Term s' (ell (PAsData k) :--> ell (PAsData k))
-> Term s' (ell (PAsData k)) -> Term s' (ell (PAsData k))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
self Term
  s'
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ell (PAsData k))
-> Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s' (ell (PAsData k))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s' (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
acc)

{- | Compare two key-value pairs by their keys. Gives 'PTrue' if the key of the
 first argument pair is less than the key of the second argument pair.

 @since 2.1.1
-}
pkvPairLt ::
  forall (k :: S -> Type) (v :: S -> Type) (s :: S).
  (PIsData k, POrd k) =>
  Term
    s
    ( PBuiltinPair (PAsData k) (PAsData v)
        :--> PBuiltinPair (PAsData k) (PAsData v)
        :--> PBool
    )
pkvPairLt :: forall (k :: S -> Type) (v :: S -> Type) (s :: S).
(PIsData k, POrd k) =>
Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
pkvPairLt = ClosedTerm
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   (PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
 -> Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)))
-> ClosedTerm
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
forall a b. (a -> b) -> a -> b
$
  (Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term
     s (c :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
plam ((Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
 -> Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s PBool)
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData k) (PAsData v))
kv Term s (PBuiltinPair (PAsData k) (PAsData v))
kv' ->
    (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv) Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
forall (k :: S -> Type) (v :: S -> Type) (s :: S).
PIsData k =>
Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
pkvPairKey Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v)) -> Term s k
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
kv')

-- Helpers

-- | Rebuild the map at the given key.
rebuildAtKey ::
  forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type) (s :: S).
  ( POrd k
  , PIsData k
  ) =>
  Term
    s
    ( ( PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      )
        :--> k
        :--> PMap g k v
        :--> PMap g k v
    )
rebuildAtKey :: forall (g :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
(POrd k, PIsData k) =>
Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap g k v :--> PMap g k v)))
rebuildAtKey = ClosedTerm
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
   :--> (k :--> (PMap g k v :--> PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
      :--> (k :--> (PMap g k v :--> PMap g k v)))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
   ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    :--> (k :--> (PMap g k v :--> PMap g k v)))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
       :--> (k :--> (PMap g k v :--> PMap g k v))))
-> ClosedTerm
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
      :--> (k :--> (PMap g k v :--> PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
      :--> (k :--> (PMap g k v :--> PMap g k v)))
forall a b. (a -> b) -> a -> b
$
  (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s k -> Term s (PMap g k v) -> Term s (PMap g k v))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
      :--> (k :--> (PMap g k v :--> PMap g k v)))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s k -> Term s (PMap g k v) -> Term s (PMap g k v))
-> Term s (c :--> (k :--> (PMap g k v :--> PMap g k v)))
plam ((Term
    s
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s k -> Term s (PMap g k v) -> Term s (PMap g k v))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
       :--> (k :--> (PMap g k v :--> PMap g k v))))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s k -> Term s (PMap g k v) -> Term s (PMap g k v))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
      :--> (k :--> (PMap g k v :--> PMap g k v)))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
handler Term s k
key Term s (PMap g k v)
m ->
    Term s (PInner (PMap g k v)) -> Term s (PMap g k v)
forall (s :: S) (a :: S -> Type). Term s (PInner a) -> Term s a
punsafeDowncast (Term s (PInner (PMap g k v)) -> Term s (PMap g k v))
-> Term s (PInner (PMap g k v)) -> Term s (PMap g k v)
forall a b. (a -> b) -> a -> b
$
      (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PInner (PMap g k v))
          :--> PInner (PMap g k v)))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PInner (PMap g k v))
       :--> PInner (PMap g k v)))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> PInner (PMap g k v))
             :--> PInner (PMap g k v)))
    -> Term
         s
         ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PInner (PMap g k v))
          :--> PInner (PMap g k v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PInner (PMap g k v))
            :--> PInner (PMap g k v)))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type) (s :: S)
       (r :: S -> Type).
PIsListLike list a =>
(Term s (list a :--> r) -> Term s a -> Term s (list a) -> Term s r)
-> (Term s (list a :--> r) -> Term s r) -> Term s (list a :--> r)
precList
        ( \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> PInner (PMap g k v))
         :--> PInner (PMap g k v)))
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs ->
            Term s k
-> (Term s k
    -> Term
         s
         ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PInner (PMap g k v))
          :--> PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData k) -> Term s k) -> Term s (PAsData k) -> Term s k
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x) ((Term s k
  -> Term
       s
       ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PInner (PMap g k v))
        :--> PInner (PMap g k v)))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PInner (PMap g k v))
       :--> PInner (PMap g k v)))
-> (Term s k
    -> Term
         s
         ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> PInner (PMap g k v))
          :--> PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a b. (a -> b) -> a -> b
$ \Term s k
k ->
              (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PInner (PMap g k v))
 -> Term s (PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PInner (PMap g k v)))
-> Term s (c :--> PInner (PMap g k v))
plam ((Term
    s
    (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> PInner (PMap g k v))
  -> Term s (PInner (PMap g k v)))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PInner (PMap g k v))
       :--> PInner (PMap g k v)))
-> (Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
    -> Term s (PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
prefix ->
                Term s PBool
-> Term s (PInner (PMap g k v))
-> Term s (PInner (PMap g k v))
-> Term s (PInner (PMap g k v))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                  (Term s k
k Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s k
key)
                  (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> PInner (PMap g k v))
         :--> PInner (PMap g k v)))
self Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> PInner (PMap g k v))
         :--> PInner (PMap g k v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PInner (PMap g k v))
   :--> PInner (PMap g k v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PInner (PMap g k v))
-> Term s (PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PInner (PMap g k v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PInner (PMap g k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PInner (PMap g k v)))
-> Term s (c :--> PInner (PMap g k v))
plam ((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PInner (PMap g k v)))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v)))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PInner (PMap g k v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PInner (PMap g k v))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
suffix -> Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
prefix Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
suffix)
                  ( Term s PBool
-> Term s (PInner (PMap g k v))
-> Term s (PInner (PMap g k v))
-> Term s (PInner (PMap g k v))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                      (Term s k
k Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s k
key)
                      (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
prefix Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
handler Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs)
                      (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
prefix Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
handler Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs)
                  )
        )
        (Term
  s
  ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PInner (PMap g k v))
   :--> PInner (PMap g k v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PInner (PMap g k v))
            :--> PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a b. a -> b -> a
const (Term
   s
   ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
     :--> PInner (PMap g k v))
    :--> PInner (PMap g k v))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> PInner (PMap g k v))
             :--> PInner (PMap g k v)))
 -> Term
      s
      ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PInner (PMap g k v))
       :--> PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PInner (PMap g k v))
            :--> PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a b. (a -> b) -> a -> b
$ (Term
   s
   (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    :--> PInner (PMap g k v))
 -> Term s (PInner (PMap g k v)))
-> Term
     s
     ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> PInner (PMap g k v))
      :--> PInner (PMap g k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PInner (PMap g k v)))
-> Term s (c :--> PInner (PMap g k v))
plam (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PInner (PMap g k v))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PInner (PMap g k v))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
handler Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (PBuiltinList a)
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a)
pnil))
        # pto m
        # plam id

-- TODO: Get rid of this whole mess.
type SomeMergeHandler (k :: S -> Type) (v :: S -> Type) (s :: S) =
  SomeMergeHandler_ (->) (Term s k) (Term s v)

-- Signals how to handle value merging for matching keys in 'PPrelude.pzipWith'.
data SomeMergeHandler_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type)
  = SomeMergeHandlerCommutative (MergeHandlerCommutative_ f k v)
  | SomeMergeHandler (MergeHandler_ f k v)

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (SomeMergeHandler_ f k v)

type MergeHandler (k :: S -> Type) (v :: S -> Type) (s :: S) =
  MergeHandler_ (->) (Term s k) (Term s v)

{- Signals how to handle value merging for matching keys in 'PPrelude.pzipWith'.

 No restrictions on commutativity: Safe to use for both commutative and
 non-commutative merging operations.
-}
data MergeHandler_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type) = MergeHandler
  { forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> BothPresentHandler_ f k v
mhBoth :: BothPresentHandler_ f k v
  , forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> OnePresentHandler_ f k v
mhLeft :: OnePresentHandler_ f k v
  , forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> OnePresentHandler_ f k v
mhRight :: OnePresentHandler_ f k v
  }

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (MergeHandler_ f k v)

type MergeHandlerCommutative (k :: S -> Type) (v :: S -> Type) (s :: S) =
  MergeHandlerCommutative_ (->) (Term s k) (Term s v)

{- Signals how to handle value merging for matching keys in 'PPrelude.pzipWith'.

 Safe to use for commutative merging operations only.
-}
data MergeHandlerCommutative_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type) = MergeHandlerCommutative
  { forall (f :: Type -> Type -> Type) k v.
MergeHandlerCommutative_ f k v
-> BothPresentHandlerCommutative_ f k v
mhcBoth :: BothPresentHandlerCommutative_ f k v
  , forall (f :: Type -> Type -> Type) k v.
MergeHandlerCommutative_ f k v -> OnePresentHandler_ f k v
mhcOne :: OnePresentHandler_ f k v
  }

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (MergeHandlerCommutative_ f k v)

type BothPresentHandler (k :: S -> Type) (v :: S -> Type) (s :: S) =
  BothPresentHandler_ (->) (Term s k) (Term s v)

data BothPresentHandler_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type)
  = DropBoth
  | -- True ~ left, False ~ right
    PassArg Bool
  | HandleBoth (k `f` (v `f` (v `f` v)))

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (BothPresentHandler_ f k v)

type BothPresentHandlerCommutative (k :: S -> Type) (v :: S -> Type) (s :: S) =
  BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)

data BothPresentHandlerCommutative_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type)
  = DropBothCommutative
  | HandleBothCommutative (k `f` (v `f` (v `f` v)))

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (BothPresentHandlerCommutative_ f k v)

type OnePresentHandler (k :: S -> Type) (v :: S -> Type) (s :: S) =
  OnePresentHandler_ (->) (Term s k) (Term s v)

data OnePresentHandler_ (f :: Type -> Type -> Type) (k :: Type) (v :: Type)
  = DropOne
  | PassOne
  | HandleOne (k `f` (v `f` v))

deriving stock instance
  (forall a b. Show (f a b)) =>
  Show (OnePresentHandler_ f k v)

unionMergeHandler ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  Commutativity ->
  Term s (v :--> (v :--> v)) ->
  SomeMergeHandler k v s
unionMergeHandler :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
unionMergeHandler Commutativity
NonCommutative Term s (v :--> (v :--> v))
merge =
  MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler_ (->) (Term s k) (Term s v))
-> MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall a b. (a -> b) -> a -> b
$ BothPresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler ((Term s k -> (Term s v -> (Term s v -> Term s v)))
-> BothPresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandler_ f k v
HandleBoth \Term s k
_ Term s v
vl Term s v
vr -> Term s (v :--> (v :--> v))
merge Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr) OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne
unionMergeHandler Commutativity
Commutative Term s (v :--> (v :--> v))
merge =
  MergeHandlerCommutative_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
MergeHandlerCommutative_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandlerCommutative (MergeHandlerCommutative_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler_ (->) (Term s k) (Term s v))
-> MergeHandlerCommutative_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall a b. (a -> b) -> a -> b
$
    BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandlerCommutative_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandlerCommutative_ f k v
-> OnePresentHandler_ f k v -> MergeHandlerCommutative_ f k v
MergeHandlerCommutative ((Term s k -> (Term s v -> (Term s v -> Term s v)))
-> BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandlerCommutative_ f k v
HandleBothCommutative \Term s k
_ Term s v
vl Term s v
vr -> Term s (v :--> (v :--> v))
merge Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr) OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne

{- Zip two 'PMap's, using a 'SomeMergeHandler' to decide how to merge based on key
 presence on the left and right.

 Note that using a 'MergeHandlerCommutative' is less costly than a 'MergeHandler'.
-}
pzipWith ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  ( POrd k
  , PIsData k
  , PIsData v
  ) =>
  SomeMergeHandler k v s ->
  Term
    s
    ( PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
    )
pzipWith :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k, PIsData v) =>
SomeMergeHandler k v s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWith (SomeMergeHandler MergeHandler_ (->) (Term s k) (Term s v)
mh) =
  SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWithData (MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
 -> SomeMergeHandler (PAsData k) (PAsData v) s)
-> MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall a b. (a -> b) -> a -> b
$ MergeHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
MergeHandler k v s -> MergeHandler (PAsData k) (PAsData v) s
mergeHandlerOnData MergeHandler_ (->) (Term s k) (Term s v)
mh)
pzipWith (SomeMergeHandlerCommutative MergeHandlerCommutative_ (->) (Term s k) (Term s v)
mhc) =
  SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWithData (MergeHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
MergeHandlerCommutative_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandlerCommutative (MergeHandlerCommutative_
   (->) (Term s (PAsData k)) (Term s (PAsData v))
 -> SomeMergeHandler (PAsData k) (PAsData v) s)
-> MergeHandlerCommutative_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> SomeMergeHandler (PAsData k) (PAsData v) s
forall a b. (a -> b) -> a -> b
$ MergeHandlerCommutative_ (->) (Term s k) (Term s v)
-> MergeHandlerCommutative_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
MergeHandlerCommutative k v s
-> MergeHandlerCommutative (PAsData k) (PAsData v) s
mergeHandlerCommutativeOnData MergeHandlerCommutative_ (->) (Term s k) (Term s v)
mhc)

{- Zip two 'PMap's, using a 'SomeMergeHandler' to decide how to merge based on key
 presence on the left and right.

 Note that using a 'MergeHandlerCommutative' is less costly than a 'MergeHandler'.
-}
pzipWithData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  ( POrd k
  , PIsData k
  ) =>
  SomeMergeHandler (PAsData k) (PAsData v) s ->
  Term
    s
    ( PMap 'Sorted k v
        :--> PMap 'Sorted k v
        :--> PMap 'Sorted k v
    )
pzipWithData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
SomeMergeHandler (PAsData k) (PAsData v) s
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
pzipWithData (SomeMergeHandler mh :: MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
mh@(MergeHandler BothPresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
_ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
_ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent)) =
  (Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term s (c :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
plam ((Term s (PMap 'Sorted k v)
  -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (PMap 'Sorted k v)
    -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap 'Sorted k v)
x Term s (PMap 'Sorted k v)
y ->
    PMap 'Sorted k v s -> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
-> PMap 'Sorted k v s -> Term s (PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Sorted k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> PMap 'Sorted k v s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Sorted k v s
forall a b. (a -> b) -> a -> b
$ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMerge OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent (MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
MergeHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
zipMergeInsert MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
mh) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
y
pzipWithData (SomeMergeHandlerCommutative mh :: MergeHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
mh@(MergeHandlerCommutative BothPresentHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
_ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent)) =
  (Term s (PMap 'Sorted k v)
 -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term s (c :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
plam ((Term s (PMap 'Sorted k v)
  -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
 -> Term
      s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
-> (Term s (PMap 'Sorted k v)
    -> Term s (PMap 'Sorted k v) -> Term s (PMap 'Sorted k v))
-> Term
     s (PMap 'Sorted k v :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))
forall a b. (a -> b) -> a -> b
$ \Term s (PMap 'Sorted k v)
x Term s (PMap 'Sorted k v)
y ->
    PMap 'Sorted k v s -> Term s (PMap 'Sorted k v)
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon (PMap 'Sorted k v s -> Term s (PMap 'Sorted k v))
-> PMap 'Sorted k v s -> Term s (PMap 'Sorted k v)
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Sorted k v s
forall (keysort :: KeyGuarantees) (k :: S -> Type) (v :: S -> Type)
       (s :: S).
Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap keysort k v s
PMap (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> PMap 'Sorted k v s)
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> PMap 'Sorted k v s
forall a b. (a -> b) -> a -> b
$ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeCommutative OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent (MergeHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
MergeHandlerCommutative (PAsData k) (PAsData v) s
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMergeInsertCommutative MergeHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
mh) Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Sorted k v) -> Term s (PInner (PMap 'Sorted k v))
forall (s :: S) (a :: S -> Type). Term s a -> Term s (PInner a)
pto Term s (PMap 'Sorted k v)
y

mergeHandlerOnData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  (PIsData k, PIsData v) =>
  MergeHandler k v s ->
  MergeHandler (PAsData k) (PAsData v) s
mergeHandlerOnData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
MergeHandler k v s -> MergeHandler (PAsData k) (PAsData v) s
mergeHandlerOnData (MergeHandler BothPresentHandler_ (->) (Term s k) (Term s v)
bothPresent OnePresentHandler_ (->) (Term s k) (Term s v)
leftPresent OnePresentHandler_ (->) (Term s k) (Term s v)
rightPresent) =
  BothPresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> MergeHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler (BothPresentHandler_ (->) (Term s k) (Term s v)
-> BothPresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
BothPresentHandler k v s
-> BothPresentHandler (PAsData k) (PAsData v) s
bothPresentOnData BothPresentHandler_ (->) (Term s k) (Term s v)
bothPresent) (OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
OnePresentHandler k v s
-> OnePresentHandler (PAsData k) (PAsData v) s
onePresentOnData OnePresentHandler_ (->) (Term s k) (Term s v)
leftPresent) (OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
OnePresentHandler k v s
-> OnePresentHandler (PAsData k) (PAsData v) s
onePresentOnData OnePresentHandler_ (->) (Term s k) (Term s v)
rightPresent)

mergeHandlerCommutativeOnData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  (PIsData k, PIsData v) =>
  MergeHandlerCommutative k v s ->
  MergeHandlerCommutative (PAsData k) (PAsData v) s
mergeHandlerCommutativeOnData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
MergeHandlerCommutative k v s
-> MergeHandlerCommutative (PAsData k) (PAsData v) s
mergeHandlerCommutativeOnData (MergeHandlerCommutative BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
bothPresent OnePresentHandler_ (->) (Term s k) (Term s v)
onePresent) =
  BothPresentHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> MergeHandlerCommutative_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (f :: Type -> Type -> Type) k v.
BothPresentHandlerCommutative_ f k v
-> OnePresentHandler_ f k v -> MergeHandlerCommutative_ f k v
MergeHandlerCommutative (BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
-> BothPresentHandlerCommutative_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
BothPresentHandlerCommutative k v s
-> BothPresentHandlerCommutative (PAsData k) (PAsData v) s
bothPresentCommutativeOnData BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
bothPresent) (OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
OnePresentHandler k v s
-> OnePresentHandler (PAsData k) (PAsData v) s
onePresentOnData OnePresentHandler_ (->) (Term s k) (Term s v)
onePresent)

zipMerge ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  OnePresentHandler (PAsData k) (PAsData v) s ->
  Term
    s
    ( PSBool
        :--> PBuiltinPair (PAsData k) (PAsData v)
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    ) ->
  Term
    s
    ( PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    )
zipMerge :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMerge OnePresentHandler (PAsData k) (PAsData v) s
rightPresent Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
mergeInsertRec = (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
plam ((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \case
  PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
PNil ->
    case OnePresentHandler (PAsData k) (PAsData v) s
rightPresent of
      OnePresentHandler (PAsData k) (PAsData v) s
DropOne -> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
forall (a :: S -> Type) (s :: S). PBuiltinList a s
PNil
      OnePresentHandler (PAsData k) (PAsData v) s
PassOne -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs
      HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
        Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap
          # plam
            ( \pair ->
                plet (pfstBuiltin # pair) \k ->
                  ppairDataBuiltin # k # handler k (psndBuiltin # pair)
            )
          # rs
  PCons Term s (PBuiltinPair (PAsData k) (PAsData v))
l Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls' -> Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
mergeInsertRec Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term s PSBool
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PSBool
forall (s :: S). Term s PSBool
pstrue Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
l Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs

zipMergeInsert ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  ( POrd k
  , PIsData k
  ) =>
  MergeHandler (PAsData k) (PAsData v) s ->
  -- | 'PSTrue' means first arg is left, second arg is right.
  -- The first list gets passed in deconstructed form as head and tail
  -- separately.
  Term
    s
    ( PSBool
        :--> PBuiltinPair (PAsData k) (PAsData v)
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    )
zipMergeInsert :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
MergeHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
zipMergeInsert (MergeHandler BothPresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
bothPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
leftPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent) = TermCont
  s
  (Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s
   (Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
 -> Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> TermCont
     s
     (Term
        s
        (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ do
  -- deduplicates all the zipMerge calls through plet, almost as good as hoisting
  Term
  s
  ((PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMerge' <- ((Term
    s
    ((PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
  -> Term
       s
       (PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
 -> Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> TermCont
     s
     (Term
        s
        ((PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   -> Term
        s
        (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
  -> Term
       s
       (PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
 -> TermCont
      s
      (Term
         s
         ((PSBool
           :--> (PBuiltinPair (PAsData k) (PAsData v)
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> ((Term
       s
       ((PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
     -> Term
          s
          (PSBool
           :--> (PBuiltinPair (PAsData k) (PAsData v)
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
    -> Term
         s
         (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> TermCont
     s
     (Term
        s
        ((PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ Term
  s
  ((PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term
      s
      ((PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term
         s
         (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term
   s
   ((PSBool
     :--> (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> (Term
       s
       ((PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
     -> Term
          s
          (PSBool
           :--> (PBuiltinPair (PAsData k) (PAsData v)
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
 -> Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term
      s
      ((PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term
         s
         (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ (Term
   s
   (PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
plam ((Term
    s
    (PSBool
     :--> (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
  -> Term
       s
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> Term
      s
      ((PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> (Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    -> Term
         s
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a b. (a -> b) -> a -> b
$ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMerge OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent
  Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> TermCont
     s
     (Term
        s
        (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term
   s
   (PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> TermCont
      s
      (Term
         s
         (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> TermCont
     s
     (Term
        s
        (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
forall a b. (a -> b) -> a -> b
$ Term
  s
  (((PSBool
     :--> (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    :--> (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
   :--> (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PSBool
     :--> (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    :--> (PSBool
          :--> (PBuiltinPair (PAsData k) (PAsData v)
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
   :--> (PSBool
         :--> (PBuiltinPair (PAsData k) (PAsData v)
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                           :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PSBool
            :--> (PBuiltinPair (PAsData k) (PAsData v)
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> Term s PSBool
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PSBool
            :--> (PBuiltinPair (PAsData k) (PAsData v)
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s PSBool
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (c
      :--> (PSBool
            :--> (PBuiltinPair (PAsData k) (PAsData v)
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
plam ((Term
    s
    (PSBool
     :--> (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
  -> Term s PSBool
  -> Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term
      s
      ((PSBool
        :--> (PBuiltinPair (PAsData k) (PAsData v)
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                          :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
       :--> (PSBool
             :--> (PBuiltinPair (PAsData k) (PAsData v)
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))))
-> (Term
      s
      (PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    -> Term s PSBool
    -> Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     ((PSBool
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
      :--> (PSBool
            :--> (PBuiltinPair (PAsData k) (PAsData v)
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
self Term s PSBool
argOrder' Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys -> TermCont
  s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ do
    let zipMergeRec :: Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec = Term
  s
  ((PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMerge' Term
  s
  ((PSBool
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PSBool
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
self
        xs :: Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs = Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
        zipMergeOrdered :: Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
zipMergeOrdered Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xSide Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ySide =
          Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder -> PSBool s
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PSBool s
-> Term s (a :--> (a :--> b)) -> Term s a -> Term s a -> Term s b
applyOrder PSBool s
argOrder Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xSide Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ySide
    Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
PNil -> Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder ->
        -- picking handler for presence of x-side only
        case PSBool s
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
leftPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent of
          OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
forall (a :: S -> Type) (s :: S). PBuiltinList a s
PNil
          OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
          HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
            Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap
              # plam
                ( \pair ->
                    plet (pfstBuiltin # pair) \k ->
                      ppairDataBuiltin # k # handler k (psndBuiltin # pair)
                )
              # xs
      PCons Term s (PBuiltinPair (PAsData k) (PAsData v))
y1 Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys' -> TermCont
  s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ do
        Term s (PBuiltinPair (PAsData k) (PAsData v))
y <- ((Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v)))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinPair (PAsData k) (PAsData v))
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v))))
-> ((Term s (PBuiltinPair (PAsData k) (PAsData v))
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet Term s (PBuiltinPair (PAsData k) (PAsData v))
y1
        Term s (PAsData k)
xk <- ((Term s (PAsData k)
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PAsData k)
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PAsData k)))
-> ((Term s (PAsData k)
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData k)
-> (Term s (PAsData k)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x)
        Term s (PAsData k)
yk <- ((Term s (PAsData k)
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PAsData k)
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PAsData k)))
-> ((Term s (PAsData k)
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData k)
-> (Term s (PAsData k)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y)
        Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$
          Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
            (Term s (PAsData k)
xk Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (s :: S).
Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData k)
yk)
            ( case BothPresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
bothPresent of
                BothPresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropBoth -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
zipMergeOrdered Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys'
                PassArg Bool
passLeft -> Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder ->
                  Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                    # (if passLeft == (argOrder == PSTrue) then x else y)
                    # applyOrder argOrder zipMergeRec xs' ys'
                HandleBoth Term s (PAsData k)
-> (Term s (PAsData v)
    -> (Term s (PAsData v) -> Term s (PAsData v)))
merge -> Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder ->
                  Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                    # ( ppairDataBuiltin
                          # xk
                          #$ applyOrder' argOrder (merge xk) (psndBuiltin # x) (psndBuiltin # y)
                      )
                    #$ applyOrder argOrder zipMergeRec xs' ys'
            )
            ( Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
xk Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
yk)
                ( Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder ->
                    -- picking handler for presence of only x-side
                    case PSBool s
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
leftPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent of
                      OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
self Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term s PSBool
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# PSBool s -> Term s PSBool -> Term s PSBool -> Term s PSBool
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder Term s PSBool
forall (s :: S). Term s PSBool
psfalse Term s PSBool
forall (s :: S). Term s PSBool
pstrue Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
                      OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# PSBool s
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PSBool s
-> Term s (a :--> (a :--> b)) -> Term s a -> Term s a -> Term s b
applyOrder PSBool s
argOrder Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys
                      HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
                        Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                          # (ppairDataBuiltin # xk # handler xk (psndBuiltin # x))
                          # (self # branchOrder argOrder psfalse pstrue # y # ys' # xs')
                )
                ( Term s PSBool
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PSBool
argOrder' ((PSBool s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PSBool s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \PSBool s
argOrder ->
                    -- picking handler for presence of only y-side
                    case PSBool s
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
-> OnePresentHandler_
     (->) (Term s (PAsData k)) (Term s (PAsData v))
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
rightPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
leftPresent of
                      OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
self Term
  s
  (PSBool
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term s PSBool
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PSBool
argOrder' Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys'
                      OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# PSBool s
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PSBool s
-> Term s (a :--> (a :--> b)) -> Term s a -> Term s a -> Term s b
applyOrder PSBool s
argOrder Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys'
                      HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
                        Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                          # (ppairDataBuiltin # yk # handler yk (psndBuiltin # y))
                          # (self # argOrder' # x # xs' # ys')
                )
            )

zipMergeCommutative ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  OnePresentHandler (PAsData k) (PAsData v) s ->
  Term
    s
    ( PBuiltinPair (PAsData k) (PAsData v)
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    ) ->
  Term
    s
    ( PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    )
zipMergeCommutative :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeCommutative OnePresentHandler (PAsData k) (PAsData v) s
onePresent Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
mergeInsertRec = (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
plam ((Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \case
  PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
PNil ->
    case OnePresentHandler (PAsData k) (PAsData v) s
onePresent of
      OnePresentHandler (PAsData k) (PAsData v) s
DropOne -> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
forall (a :: S -> Type) (s :: S). PBuiltinList a s
PNil
      OnePresentHandler (PAsData k) (PAsData v) s
PassOne -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs
      HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
        Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap
          # plam
            ( \pair ->
                plet (pfstBuiltin # pair) \k ->
                  ppairDataBuiltin # k # handler k (psndBuiltin # pair)
            )
          # rs
  PCons Term s (PBuiltinPair (PAsData k) (PAsData v))
l Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls' -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
mergeInsertRec Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
l Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ls' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
rs

zipMergeInsertCommutative ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  ( POrd k
  , PIsData k
  ) =>
  MergeHandlerCommutative (PAsData k) (PAsData v) s ->
  -- | 'PSTrue' means first arg is left, second arg is right.
  -- The first list gets passed in deconstructed form as head and tail
  -- separately.
  Term
    s
    ( PBuiltinPair (PAsData k) (PAsData v)
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
    )
zipMergeInsertCommutative :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(POrd k, PIsData k) =>
MergeHandlerCommutative (PAsData k) (PAsData v) s
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMergeInsertCommutative (MergeHandlerCommutative BothPresentHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
bothPresent OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent) = TermCont
  s
  (Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s
   (Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> TermCont
     s
     (Term
        s
        (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a b. (a -> b) -> a -> b
$ do
  -- deduplicates all the zipMerge calls through plet, almost as good as hoisting
  Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMerge' <- ((Term
    s
    ((PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
  -> Term
       s
       (PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> TermCont
     s
     (Term
        s
        ((PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   -> Term
        s
        (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
  -> Term
       s
       (PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> TermCont
      s
      (Term
         s
         ((PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> ((Term
       s
       ((PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
     -> Term
          s
          (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
    -> Term
         s
         (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> TermCont
     s
     (Term
        s
        ((PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term
         s
         (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term
   s
   ((PBuiltinPair (PAsData k) (PAsData v)
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> (Term
       s
       ((PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
     -> Term
          s
          (PBuiltinPair (PAsData k) (PAsData v)
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                       :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
 -> Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> (Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term
         s
         (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a b. (a -> b) -> a -> b
$ (Term
   s
   (PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term
      s
      (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (c
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
plam ((Term
    s
    (PBuiltinPair (PAsData k) (PAsData v)
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
  -> Term
       s
       (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> (Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term
         s
         (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall a b. (a -> b) -> a -> b
$ OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (k :: S -> Type) (v :: S -> Type).
OnePresentHandler (PAsData k) (PAsData v) s
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeCommutative OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent
  Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> TermCont
     s
     (Term
        s
        (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term
   s
   (PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> TermCont
      s
      (Term
         s
         (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> TermCont
     s
     (Term
        s
        (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ Term
  s
  (((PBuiltinPair (PAsData k) (PAsData v)
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b))
pfix Term
  s
  (((PBuiltinPair (PAsData k) (PAsData v)
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    :--> (PBuiltinPair (PAsData k) (PAsData v)
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
   :--> (PBuiltinPair (PAsData k) (PAsData v)
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                     :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
#$ (Term
   s
   (PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c
 -> Term s (PBuiltinPair (PAsData k) (PAsData v))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     (c
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
plam ((Term
    s
    (PBuiltinPair (PAsData k) (PAsData v)
     :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
           :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                 :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
  -> Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term
      s
      ((PBuiltinPair (PAsData k) (PAsData v)
        :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
              :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                    :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
       :--> (PBuiltinPair (PAsData k) (PAsData v)
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))))
-> (Term
      s
      (PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
    -> Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term
     s
     ((PBuiltinPair (PAsData k) (PAsData v)
       :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
             :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
      :--> (PBuiltinPair (PAsData k) (PAsData v)
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                        :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))))
forall a b. (a -> b) -> a -> b
$ \Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
self Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys -> TermCont
  s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ do
    let zipMergeRec :: Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec = Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
zipMerge' Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
          :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinPair (PAsData k) (PAsData v)
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
                  :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
self
        xs :: Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs = Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
    Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys ((PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ \case
      PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
PNil ->
        -- picking handler for presence of x-side only
        case OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent of
          OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). PlutusType a => a s -> Term s a
pcon PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)) s
forall (a :: S -> Type) (s :: S). PBuiltinList a s
PNil
          OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
          HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
            Term
  s
  ((PBuiltinPair (PAsData k) (PAsData v)
    :--> PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (b :: S -> Type) (s :: S).
(PListLike list, PElemConstraint list a, PElemConstraint list b) =>
Term s ((a :--> b) :--> (list a :--> list b))
PPrelude.pmap
              # plam
                ( \pair ->
                    plet (pfstBuiltin # pair) \k ->
                      ppairDataBuiltin # k # handler k (psndBuiltin # pair)
                )
              # xs
      PCons Term s (PBuiltinPair (PAsData k) (PAsData v))
y1 Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys' -> TermCont
  s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
unTermCont (TermCont
   s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ do
        Term s (PBuiltinPair (PAsData k) (PAsData v))
y <- ((Term s (PBuiltinPair (PAsData k) (PAsData v))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v)))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PBuiltinPair (PAsData k) (PAsData v))
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v))))
-> ((Term s (PBuiltinPair (PAsData k) (PAsData v))
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PBuiltinPair (PAsData k) (PAsData v)))
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinPair (PAsData k) (PAsData v))
-> (Term s (PBuiltinPair (PAsData k) (PAsData v))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet Term s (PBuiltinPair (PAsData k) (PAsData v))
y1
        Term s (PAsData k)
xk <- ((Term s (PAsData k)
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PAsData k)
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PAsData k)))
-> ((Term s (PAsData k)
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData k)
-> (Term s (PAsData k)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x)
        Term s (PAsData k)
yk <- ((Term s (PAsData k)
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a (s :: S) (r :: S -> Type).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont (((Term s (PAsData k)
   -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
  -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
 -> TermCont s (Term s (PAsData k)))
-> ((Term s (PAsData k)
     -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> TermCont s (Term s (PAsData k))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData k)
-> (Term s (PAsData k)
    -> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s a -> (Term s a -> Term s b) -> Term s b
plet (Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term s (PBuiltinPair (PAsData k) (PAsData v) :--> PAsData k)
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term s (PAsData k)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y)
        Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
 -> TermCont
      s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> TermCont
     s (Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall a b. (a -> b) -> a -> b
$
          Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
            (Term s (PAsData k)
xk Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (s :: S).
Term s (PAsData k) -> Term s (PAsData k) -> Term s PBool
forall (t :: S -> Type) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PAsData k)
yk)
            ( case BothPresentHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
bothPresent of
                BothPresentHandlerCommutative_
  (->) (Term s (PAsData k)) (Term s (PAsData v))
DropBothCommutative -> Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys'
                HandleBothCommutative Term s (PAsData k)
-> (Term s (PAsData v)
    -> (Term s (PAsData v) -> Term s (PAsData v)))
merge ->
                  Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                    # ( ppairDataBuiltin
                          # xk
                          #$ merge xk (psndBuiltin # x) (psndBuiltin # y)
                      )
                    #$ zipMergeRec
                    # xs'
                    # ys'
            )
            ( Term s PBool
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (a :: S -> Type) (s :: S).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
                (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
xk Term s k -> Term s k -> Term s PBool
forall (s :: S). Term s k -> Term s k -> Term s PBool
forall (t :: S -> Type) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
yk)
                ( case OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent of
                    OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
self Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs'
                    OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys)
                    HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
                      Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                        # (ppairDataBuiltin # xk # handler xk (psndBuiltin # x))
                        # (self # y # ys' # xs')
                )
                ( case OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
onePresent of
                    OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
DropOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
self Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
               :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
            :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
x Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys'
                    OnePresentHandler_ (->) (Term s (PAsData k)) (Term s (PAsData v))
PassOne -> Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinPair (PAsData k) (PAsData v))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData k) (PAsData v))
y Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
zipMergeRec Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term
     s
     (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
      :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
ys' Term
  s
  (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
   :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
-> Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v)))
xs)
                    HandleOne Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v))
handler ->
                      Term
  s
  (PBuiltinPair (PAsData k) (PAsData v)
   :--> (PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))
         :--> PBuiltinList (PBuiltinPair (PAsData k) (PAsData v))))
forall (a :: S -> Type) (s :: S).
PElemConstraint PBuiltinList a =>
Term s (a :--> (PBuiltinList a :--> PBuiltinList a))
forall (list :: (S -> Type) -> S -> Type) (a :: S -> Type)
       (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (a :--> (list a :--> list a))
pcons
                        # (ppairDataBuiltin # yk # handler yk (psndBuiltin # y))
                        # (self # x # xs' # ys')
                )
            )

bothPresentOnData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  (PIsData k, PIsData v) =>
  BothPresentHandler k v s ->
  BothPresentHandler (PAsData k) (PAsData v) s
bothPresentOnData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
BothPresentHandler k v s
-> BothPresentHandler (PAsData k) (PAsData v) s
bothPresentOnData = \case
  BothPresentHandler k v s
DropBoth -> BothPresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v. BothPresentHandler_ f k v
DropBoth
  PassArg Bool
arg -> Bool -> BothPresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
Bool -> BothPresentHandler_ f k v
PassArg Bool
arg
  HandleBoth Term s k -> (Term s v -> (Term s v -> Term s v))
f -> (Term s (PAsData k)
 -> (Term s (PAsData v)
     -> (Term s (PAsData v) -> Term s (PAsData v))))
-> BothPresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandler_ f k v
HandleBoth \Term s (PAsData k)
k Term s (PAsData v)
x Term s (PAsData v)
y -> Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s v -> Term s (PAsData v)) -> Term s v -> Term s (PAsData v)
forall a b. (a -> b) -> a -> b
$ Term s k -> (Term s v -> (Term s v -> Term s v))
f (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
k) (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData v)
x) (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData v)
y)

onePresentOnData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  (PIsData k, PIsData v) =>
  OnePresentHandler k v s ->
  OnePresentHandler (PAsData k) (PAsData v) s
onePresentOnData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
OnePresentHandler k v s
-> OnePresentHandler (PAsData k) (PAsData v) s
onePresentOnData = \case
  OnePresentHandler k v s
DropOne -> OnePresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
DropOne
  OnePresentHandler k v s
PassOne -> OnePresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
PassOne
  HandleOne Term s k -> (Term s v -> Term s v)
f -> (Term s (PAsData k) -> (Term s (PAsData v) -> Term s (PAsData v)))
-> OnePresentHandler (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
f k (f v v) -> OnePresentHandler_ f k v
HandleOne \Term s (PAsData k)
x Term s (PAsData v)
y -> Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s v -> Term s (PAsData v)) -> Term s v -> Term s (PAsData v)
forall a b. (a -> b) -> a -> b
$ Term s k -> (Term s v -> Term s v)
f (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
x) (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData v)
y)

bothPresentCommutativeOnData ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  (PIsData k, PIsData v) =>
  BothPresentHandlerCommutative k v s ->
  BothPresentHandlerCommutative (PAsData k) (PAsData v) s
bothPresentCommutativeOnData :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
(PIsData k, PIsData v) =>
BothPresentHandlerCommutative k v s
-> BothPresentHandlerCommutative (PAsData k) (PAsData v) s
bothPresentCommutativeOnData = \case
  BothPresentHandlerCommutative k v s
DropBothCommutative -> BothPresentHandlerCommutative (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
BothPresentHandlerCommutative_ f k v
DropBothCommutative
  HandleBothCommutative Term s k -> (Term s v -> (Term s v -> Term s v))
f ->
    (Term s (PAsData k)
 -> (Term s (PAsData v)
     -> (Term s (PAsData v) -> Term s (PAsData v))))
-> BothPresentHandlerCommutative (PAsData k) (PAsData v) s
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandlerCommutative_ f k v
HandleBothCommutative \Term s (PAsData k)
k Term s (PAsData v)
x Term s (PAsData v)
y -> Term s v -> Term s (PAsData v)
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s v -> Term s (PAsData v)) -> Term s v -> Term s (PAsData v)
forall a b. (a -> b) -> a -> b
$ Term s k -> (Term s v -> (Term s v -> Term s v))
f (Term s (PAsData k) -> Term s k
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData k)
k) (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData v)
x) (Term s (PAsData v) -> Term s v
forall (a :: S -> Type) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData v)
y)

-- | Apply given Plutarch fun with given reified (on Haskell-level) arg order.
applyOrder ::
  forall (s :: S) (a :: S -> Type) (b :: S -> Type).
  -- | 'PSTrue' means first arg is left, second arg is right.
  PSBool s ->
  -- | A function that expects argument order 'left right'.
  Term s (a :--> a :--> b) ->
  -- | First arg.
  Term s a ->
  -- | Second arg.
  Term s a ->
  Term s b
applyOrder :: forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PSBool s
-> Term s (a :--> (a :--> b)) -> Term s a -> Term s a -> Term s b
applyOrder PSBool s
argOrder Term s (a :--> (a :--> b))
pfun Term s a
a Term s a
b = PSBool s -> Term s b -> Term s b -> Term s b
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder (Term s (a :--> (a :--> b))
pfun Term s (a :--> (a :--> b)) -> Term s a -> Term s (a :--> b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
a Term s (a :--> b) -> Term s a -> Term s b
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
b) (Term s (a :--> (a :--> b))
pfun Term s (a :--> (a :--> b)) -> Term s a -> Term s (a :--> b)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
b Term s (a :--> b) -> Term s a -> Term s b
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s a
a)

branchOrder :: forall (s :: S) (a :: Type). PSBool s -> a -> a -> a
branchOrder :: forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
PSTrue a
t a
_ = a
t
branchOrder PSBool s
PSFalse a
_ a
f = a
f

applyOrder' ::
  forall (s :: S) (a :: Type) (b :: Type).
  -- | 'PSTrue' means first arg is left, second arg is right.
  PSBool s ->
  -- | A function that expects argument order 'left right'.
  (a -> a -> b) ->
  -- | First arg.
  a ->
  -- | Second arg.
  a ->
  b
applyOrder' :: forall (s :: S) a b. PSBool s -> (a -> a -> b) -> a -> a -> b
applyOrder' PSBool s
argOrder a -> a -> b
fun a
a a
b = PSBool s -> b -> b -> b
forall (s :: S) a. PSBool s -> a -> a -> a
branchOrder PSBool s
argOrder (a -> a -> b
fun a
a a
b) (a -> a -> b
fun a
b a
a)

defaultMergeHandlerNonCommutative ::
  forall (s :: S) (v :: S -> Type) (k :: S -> Type).
  Term s v ->
  Term s v ->
  Term s (v :--> (v :--> v)) ->
  SomeMergeHandler k v s
defaultMergeHandlerNonCommutative :: forall (s :: S) (v :: S -> Type) (k :: S -> Type).
Term s v
-> Term s v -> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
defaultMergeHandlerNonCommutative Term s v
defLeft Term s v
defRight Term s (v :--> (v :--> v))
combine =
  MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler_ (->) (Term s k) (Term s v))
-> MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall a b. (a -> b) -> a -> b
$
    BothPresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler
      ((Term s k -> (Term s v -> (Term s v -> Term s v)))
-> BothPresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandler_ f k v
HandleBoth \Term s k
_ Term s v
vl Term s v
vr -> Term s (v :--> (v :--> v))
combine Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr)
      ((Term s k -> (Term s v -> Term s v))
-> OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v v) -> OnePresentHandler_ f k v
HandleOne \Term s k
_ Term s v
vl -> Term s (v :--> (v :--> v))
combine Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
defRight)
      ((Term s k -> (Term s v -> Term s v))
-> OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v v) -> OnePresentHandler_ f k v
HandleOne \Term s k
_ Term s v
vr -> Term s (v :--> (v :--> v))
combine Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
defLeft Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr)

intersectionMergeHandler ::
  forall (s :: S) (k :: S -> Type) (v :: S -> Type).
  Commutativity ->
  Term s (v :--> (v :--> v)) ->
  SomeMergeHandler k v s
intersectionMergeHandler :: forall (s :: S) (k :: S -> Type) (v :: S -> Type).
Commutativity
-> Term s (v :--> (v :--> v)) -> SomeMergeHandler k v s
intersectionMergeHandler Commutativity
NonCommutative Term s (v :--> (v :--> v))
merge =
  MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
MergeHandler_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandler (MergeHandler_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler_ (->) (Term s k) (Term s v))
-> MergeHandler_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall a b. (a -> b) -> a -> b
$ BothPresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandler_ f k v
-> OnePresentHandler_ f k v
-> OnePresentHandler_ f k v
-> MergeHandler_ f k v
MergeHandler ((Term s k -> (Term s v -> (Term s v -> Term s v)))
-> BothPresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandler_ f k v
HandleBoth \Term s k
_ Term s v
vl Term s v
vr -> Term s (v :--> (v :--> v))
merge Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr) OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
DropOne OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
DropOne
intersectionMergeHandler Commutativity
Commutative Term s (v :--> (v :--> v))
merge =
  MergeHandlerCommutative_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
MergeHandlerCommutative_ f k v -> SomeMergeHandler_ f k v
SomeMergeHandlerCommutative (MergeHandlerCommutative_ (->) (Term s k) (Term s v)
 -> SomeMergeHandler_ (->) (Term s k) (Term s v))
-> MergeHandlerCommutative_ (->) (Term s k) (Term s v)
-> SomeMergeHandler_ (->) (Term s k) (Term s v)
forall a b. (a -> b) -> a -> b
$
    BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
-> OnePresentHandler_ (->) (Term s k) (Term s v)
-> MergeHandlerCommutative_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
BothPresentHandlerCommutative_ f k v
-> OnePresentHandler_ f k v -> MergeHandlerCommutative_ f k v
MergeHandlerCommutative ((Term s k -> (Term s v -> (Term s v -> Term s v)))
-> BothPresentHandlerCommutative_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v.
f k (f v (f v v)) -> BothPresentHandlerCommutative_ f k v
HandleBothCommutative \Term s k
_ Term s v
vl Term s v
vr -> Term s (v :--> (v :--> v))
merge Term s (v :--> (v :--> v)) -> Term s v -> Term s (v :--> v)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vl Term s (v :--> v) -> Term s v -> Term s v
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
Term s (a :--> b) -> Term s a -> Term s b
# Term s v
vr) OnePresentHandler_ (->) (Term s k) (Term s v)
forall (f :: Type -> Type -> Type) k v. OnePresentHandler_ f k v
DropOne

-- We have to clone this in here or we get a dependency cycle
passertPJust :: forall (a :: S -> Type) (s :: S). Term s (PString :--> PMaybe a :--> a)
passertPJust :: forall (a :: S -> Type) (s :: S).
Term s (PString :--> (PMaybe a :--> a))
passertPJust = ClosedTerm (PString :--> (PMaybe a :--> a))
-> Term s (PString :--> (PMaybe a :--> a))
forall (a :: S -> Type) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PString :--> (PMaybe a :--> a))
 -> Term s (PString :--> (PMaybe a :--> a)))
-> ClosedTerm (PString :--> (PMaybe a :--> a))
-> Term s (PString :--> (PMaybe a :--> a))
forall a b. (a -> b) -> a -> b
$
  (Term s PString -> Term s (PMaybe a) -> Term s a)
-> Term s (PString :--> (PMaybe a :--> a))
forall a (b :: S -> Type) (s :: S) (c :: S -> Type).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: S -> Type).
HasCallStack =>
(Term s c -> Term s (PMaybe a) -> Term s a)
-> Term s (c :--> (PMaybe a :--> a))
plam ((Term s PString -> Term s (PMaybe a) -> Term s a)
 -> Term s (PString :--> (PMaybe a :--> a)))
-> (Term s PString -> Term s (PMaybe a) -> Term s a)
-> Term s (PString :--> (PMaybe a :--> a))
forall a b. (a -> b) -> a -> b
$ \Term s PString
emsg Term s (PMaybe a)
mv' -> Term s (PMaybe a) -> (PMaybe a s -> Term s a) -> Term s a
forall (a :: S -> Type) (s :: S) (b :: S -> Type).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PMaybe a)
mv' ((PMaybe a s -> Term s a) -> Term s a)
-> (PMaybe a s -> Term s a) -> Term s a
forall a b. (a -> b) -> a -> b
$ \case
    PJust Term s a
v -> Term s a
v
    PMaybe a s
_ -> Term s PString -> Term s a
forall (a :: S -> Type) (s :: S). Term s PString -> Term s a
ptraceInfoError Term s PString
emsg