| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Plutarch.TermCont
Synopsis
- hashOpenTerm :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Term s a -> TermCont s (Hashed RawTerm)
- newtype TermCont (a :: S) b where
- runTermCont :: TermCont a b -> (b -> Term a r) -> Term a r
- unTermCont :: forall (a :: S -> Type) (s :: S). TermCont s (Term s a) -> Term s a
- tcont :: forall a (s :: S) (r :: S -> Type). ((a -> Term s r) -> Term s r) -> TermCont s a
- pfindPlaceholder :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Integer -> Term s a -> TermCont s Bool
- pletC :: forall {r :: S -> Type} (s :: S) (a :: S -> Type). Term s a -> TermCont s (Term s a)
- pmatchC :: forall {r :: S -> Type} a (s :: S). PlutusType a => Term s a -> TermCont s (a s)
- 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))
- ptraceC :: forall {r :: S -> Type} (s :: S). Term s PString -> TermCont s ()
- pguardC :: forall {r :: S -> Type} (s :: S). Term s PString -> Term s PBool -> TermCont s ()
- pguardC' :: forall (s :: S) (a :: S -> Type). Term s a -> Term s PBool -> TermCont s ()
- 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))
- pexpectJustC :: forall (a :: S -> Type) (r :: S -> Type) (s :: S). Term s r -> Term s (PMaybe a) -> TermCont s (Term s a)
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
| MonadFail (TermCont s) Source # | |
| Applicative (TermCont s) Source # | |
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 # | |
| Monad (TermCont s) 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 #
pmatchC :: forall {r :: S -> Type} a (s :: S). PlutusType a => Term s a -> TermCont s (a s) Source #
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