plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Monadic

Synopsis

Documentation

(>>=) :: (x -> Term s a) -> x -> Term s a Source #

Bind function used within do syntax.

Enables elegant usage of pmatch and similar. P.do { y <- x ; z } is equivalent to x $ y -> z.

  import qualified Plutarch.Monadic as P

  f :: Term s (PTxInfo :--> PBuiltinList (PAsData PTxInInfo))
  f = plam $ x -> P.do
    PTxInfo txInfoFields <- pmatch x
    pfromData $ pdhead # txInfoFields

(>>) :: (x -> Term s a) -> x -> Term s a Source #

Forgetful bind function used within do syntax.

Enables elegant usage of ptrace and similar. P.do { x ; y } is equivalent to x y.

  import qualified Plutarch.Monadic as P

  P.do
    ptrace "yielding unit"
    pconstant ()

fail :: String -> Term s a Source #

Implicitly invoked upon pattern match failure within do syntax.

  import qualified Plutarch.Monadic as P

  P.do
    -- calls fail, traces an error message, and invokes perror.
    PTrue <- pconstant False