plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Internal.Other

Synopsis

Documentation

printTerm :: HasCallStack => Config -> ClosedTerm a -> String Source #

Prettyprint a Term via the PLC pretty printer

TODO: Heavily improve. It's unreadable right now.

We could convert the de Bruijn indices into names with:

show . prettyPlcReadableDef . (\(Right p) -> p) . Scripts.mkTermToEvaluate . compile $ term

printScript :: Script -> String Source #

Prettyprint a compiled Script via the PLC pretty printer

pto :: Term s a -> Term s (PInner a) Source #

Safely coerce from a Term to it's PInner representation.

pfix :: Term s (((a :--> b) :--> (a :--> b)) :--> (a :--> b)) Source #

Fixpoint recursion. Used to encode recursive functions.

Example:

iterateN' ::
 Term s (PInteger :--> (a :--> a) :--> a :--> a) ->
 Term s PInteger ->
 Term s (a :--> a) ->
 Term s a
iterateN' self n f x =
  pif (n #== 0) x (self # n - 1 #$ f x)

iterateN :: Term s (PInteger :--> (a :--> a) :--> a :--> a)
iterateN = pfix #$ plam iterateN'

Further examples can be found in examples/Recursion.hs

newtype POpaque s Source #

An Arbitrary Term with an unknown type

Constructors

POpaque (Term s POpaque) 

Instances

Instances details
PlutusType POpaque Source # 
Instance details

Defined in Plutarch.Internal.Other

Methods

pcon' :: forall (s :: S). POpaque s -> Term s (PInner POpaque) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner POpaque) -> (POpaque s -> Term s b) -> Term s b Source #

type PContravariant' POpaque Source # 
Instance details

Defined in Plutarch.Internal.Other

type PCovariant' POpaque Source # 
Instance details

Defined in Plutarch.Internal.Other

type PInner POpaque Source # 
Instance details

Defined in Plutarch.Internal.Other

type PVariant' POpaque Source # 
Instance details

Defined in Plutarch.Internal.Other

type PVariant' POpaque = ()

popaque :: Term s a -> Term s POpaque Source #

Erase the type of a Term