plutarch
Safe HaskellNone
LanguageGHC2021

Plutarch.TermCont

Synopsis

Documentation

hashOpenTerm :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Term s a -> TermCont s (Hashed RawTerm) Source #

newtype TermCont (a :: S) b where Source #

Constructors

TermCont :: forall (r :: S -> Type) (a :: S) b. ((b -> Term a r) -> Term a r) -> TermCont a b 

Instances

Instances details
MonadFail (TermCont s) Source # 
Instance details

Defined in Plutarch.Internal.TermCont

Methods

fail :: String -> TermCont s a Source #

Applicative (TermCont s) Source # 
Instance details

Defined in Plutarch.Internal.TermCont

Methods

pure :: a -> TermCont s a Source #

(<*>) :: TermCont s (a -> b) -> TermCont s a -> TermCont s b Source #

liftA2 :: (a -> b -> c) -> TermCont s a -> TermCont s b -> TermCont s c Source #

(*>) :: TermCont s a -> TermCont s b -> TermCont s b Source #

(<*) :: TermCont s a -> TermCont s b -> TermCont s a Source #

Functor (TermCont s) Source # 
Instance details

Defined in Plutarch.Internal.TermCont

Methods

fmap :: (a -> b) -> TermCont s a -> TermCont s b Source #

(<$) :: a -> TermCont s b -> TermCont s a Source #

Monad (TermCont s) Source # 
Instance details

Defined in Plutarch.Internal.TermCont

Methods

(>>=) :: TermCont s a -> (a -> TermCont s b) -> TermCont s b Source #

(>>) :: TermCont s a -> TermCont s b -> TermCont s b Source #

return :: a -> TermCont s a Source #

runTermCont :: TermCont a b -> (b -> Term a r) -> Term a r Source #

unTermCont :: forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a Source #

tcont :: forall a (s :: S) (r :: S -> Type). ((a -> Term s r) -> Term s r) -> TermCont s a Source #

pfindPlaceholder :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Integer -> Term s a -> TermCont s Bool Source #

Given a term, and an integer tag, this function checks if the term holds and PPlaceholder with the given integer tag.

pletC :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Term s a -> TermCont s (Term s a) Source #

Like plet but works in a TermCont monad

pmatchC :: forall {r :: S -> Type} a (s :: S). PlutusType a => Term s a -> TermCont s (a s) Source #

Like pmatch but works in a TermCont monad

pletFieldsC :: forall (fs :: [Symbol]) (a :: S -> Type) (s :: S) (b :: S -> Type) (ps :: [PLabeledType]) (bs :: [ToBind]). (PDataFields a, ps ~ PFields a, bs ~ Bindings ps fs, BindFields ps bs) => Term s a -> TermCont s (HRec (BoundTerms ps bs s)) Source #

Deprecated: Use the new mechanism instead

Like pletFields but works in a TermCont monad.

ptraceC :: forall {r :: S -> Type} (s :: S). Term s PString -> TermCont s () Source #

Like ptrace but works in a TermCont monad.

Example ===

foo :: Term s PUnit
foo = unTermCont $ do
  ptraceC "returning unit!"
  pure $ pconstant ()

pguardC :: forall {r :: S -> Type} (s :: S). Term s PString -> Term s PBool -> TermCont s () Source #

Trace a message and raise error if cond is false. Otherwise, continue.

Example ===

onlyAllow42 :: Term s (PInteger :--> PUnit)
onlyAllow42 = plam $ i -> unTermCont $ do
  pguardC "expected 42" $ i #== 42
  pure $ pconstant ()

pguardC' :: forall (s :: S) (a :: S -> Type). Term s a -> Term s PBool -> TermCont s () Source #

Stop computation and return given term if cond is false. Otherwise, continue.

Example ===

is42 :: Term s (PInteger :--> PBool)
is42 = plam $ i -> unTermCont $ do
  pguardC' (pconstant False) $ i #== 42
  pure $ pconstant True

ptryFromC :: forall (b :: S -> Type) (r :: S -> Type) (a :: S -> Type) (s :: S). PTryFrom a b => Term s a -> TermCont s (Term s b, Reduce (PTryFromExcess a b s)) Source #

TermCont producing version of ptryFrom.

pexpectJustC :: forall (a :: S -> Type) (r :: S -> Type) (s :: S). Term s r -> Term s (PMaybe a) -> TermCont s (Term s a) Source #

Escape with a particular value on expecting PJust. For use in monadic context.

Since: 1.10.0