plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Internal.Term

Synopsis

Documentation

$hoisted

newtype ((a :: PType) :--> (b :: PType)) (s :: S) infixr 0 Source #

Constructors

PLam (Term s a -> Term s b) 

Instances

Instances details
PlutusType (a :--> b) Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

Associated Types

type PInner (a :--> b) :: PType Source #

type PCovariant' (a :--> b) Source #

type PContravariant' (a :--> b) Source #

type PVariant' (a :--> b) Source #

Methods

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

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

(a' ~ Term s a, PLamN b' b s) => PLamN (a' -> b') (a :--> b) s Source # 
Instance details

Defined in Plutarch.Internal.PLam

Methods

plam :: forall (c :: PType). HasCallStack => (Term s c -> a' -> b') -> Term s (c :--> (a :--> b)) Source #

type PContravariant' (a :--> b) Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

type PCovariant' (a :--> b) Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

type PInner (a :--> b) Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

type PInner (a :--> b) = a :--> b
type PVariant' (a :--> b) Source # 
Instance details

Defined in Plutarch.Internal.PlutusType

type PVariant' (a :--> b) = (PVariant' a, PVariant' b)

data PDelayed (a :: PType) (s :: S) Source #

$term

newtype Term (s :: S) (a :: PType) Source #

Constructors

Term 

Instances

Instances details
(IndexLabel name as ~ a, ElemOf name a as, Term s (PAsData b) ~ a, PFromDataable b c) => HasField (name :: Symbol) (HRec as) (Term s c) Source # 
Instance details

Defined in Plutarch.DataRepr.Internal.HList

Methods

getField :: HRec as -> Term s c Source #

IsString (Term s PString) Source # 
Instance details

Defined in Plutarch.Builtin.String

Monoid (Term s PByteString) Source # 
Instance details

Defined in Plutarch.Builtin.ByteString

Monoid (Term s PString) Source # 
Instance details

Defined in Plutarch.Builtin.String

Monoid (Term s PUnit) Source # 
Instance details

Defined in Plutarch.Builtin.Unit

Semigroup (Term s PByteString) Source # 
Instance details

Defined in Plutarch.Builtin.ByteString

Semigroup (Term s PString) Source # 
Instance details

Defined in Plutarch.Builtin.String

Semigroup (Term s PUnit) Source # 
Instance details

Defined in Plutarch.Builtin.Unit

PIntegralDomain a => Num (Term s a) Source # 
Instance details

Defined in Plutarch.Internal.Numeric

Methods

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

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

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

negate :: Term s a -> Term s a Source #

abs :: Term s a -> Term s a Source #

signum :: Term s a -> Term s a Source #

fromInteger :: Integer -> Term s a Source #

Fractional (Term s PRational) Source #

@since WIP

Instance details

Defined in Plutarch.Rational

newtype Script Source #

Constructors

Script (Program DeBruijn DefaultUni DefaultFun ()) 

Instances

Instances details
Generic Script Source # 
Instance details

Defined in Plutarch.Script

Associated Types

type Rep Script :: Type -> Type Source #

Show Script Source # 
Instance details

Defined in Plutarch.Script

Eq Script Source # 
Instance details

Defined in Plutarch.Script

type Rep Script Source # 
Instance details

Defined in Plutarch.Script

type Rep Script = D1 ('MetaData "Script" "Plutarch.Script" "plutarch-1.9.0-FtN0mhIoM9oEvz7Q98pjWP" 'True) (C1 ('MetaCons "Script" 'PrefixI 'True) (S1 ('MetaSel ('Just "unScript") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Program DeBruijn DefaultUni DefaultFun ()))))

plam' :: (Term s a -> Term s b) -> Term s (a :--> b) Source #

Lambda abstraction.

Only works with a single argument. Use plam instead, to support currying.

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

Let bindings.

This is approximately a shorthand for a lambda and application:

plet v f == papp (plam f) v

But sufficiently small terms in WHNF may be inlined for efficiency.

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

Lambda Application.

pdelay :: Term s a -> Term s (PDelayed a) Source #

Plutus 'delay', used for laziness.

pforce :: Term s (PDelayed a) -> Term s a Source #

Plutus 'force', used to force evaluation of PDelayed terms.

perror :: Term s a Source #

Plutus 'error'.

When using this explicitly, it should be ensured that the containing term is delayed, avoiding premature evaluation.

punsafeCoerce :: forall b a s. Term s a -> Term s b Source #

Unsafely coerce the type-tag of a Term.

This should mostly be avoided, though it can be safely used to assert known types of Datums, Redeemers or ScriptContext.

punsafeBuiltin :: DefaultFun -> Term s a Source #

punsafeConstant :: Some (ValueOf DefaultUni) -> Term s a Source #

Deprecated: Use pconstant instead.

punsafeConstantInternal :: Some (ValueOf DefaultUni) -> Term s a Source #

compile :: Config -> ClosedTerm a -> Either Text Script Source #

Compile a (closed) Plutus Term to a usable script

compileOptimized :: forall (a :: S -> Type). (forall (s :: S). Term s a) -> Either Text Script Source #

As compile, but performs UPLC optimizations. Furthermore, this will always elide tracing (as if with NoTracing).

@since WIP

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

Given a closed Term, run the UPLC optimizer on it.

Important note

If the input term has any hoisted dependencies, these are completely erased by this process. Thus, if the resulting Term is used as part of a larger computation with the same dependencies, the Plutarch compiler will not be aware of them, and will not be able to optimize them properly. More concretely, in a case like this:

@ padd # optimizeTerm (f # pexpensive) # optimizeTerm (g # pexpensive) @

pexpensive will end up being duplicated entirely into each 'arm' of the padd, even though under normal circumstances it could be shared.

Thus, if you plan to use this, ensure that it is done 'as late as possible'; embedding Terms produced by optimizeTerm into larger computations can lead to size blowout if not done carefully.

type ClosedTerm (a :: PType) = forall (s :: S). Term s a Source #

  • Closed* terms with no free variables.

type Dig = Digest Blake2b_160 Source #

data RawTerm Source #

Instances

Instances details
Show RawTerm Source # 
Instance details

Defined in Plutarch.Internal.Term

data HoistedTerm Source #

Constructors

HoistedTerm Dig RawTerm 

Instances

Instances details
Show HoistedTerm Source # 
Instance details

Defined in Plutarch.Internal.Term

data TermResult Source #

Constructors

TermResult 

data S Source #

Constructors

SI 

type PType = S -> Type Source #

Shorthand for Plutarch types.

data Config where Source #

Configuration for Plutarch scripts at compile time. This indicates whether we want to trace, and if so, under what log level and mode.

Since: 1.6.0

Bundled Patterns

pattern NoTracing :: Config

Pattern for the config that does no tracing (also the default).

Since: 1.6.0

pattern Tracing :: LogLevel -> TracingMode -> Config

Pattern for a tracing config, with both its log level and mode.

Since: 1.6.0

Instances

Instances details
FromJSON Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

parseJSON :: Value -> Parser Config

parseJSONList :: Value -> Parser [Config]

omittedField :: Maybe Config

ToJSON Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

toJSON :: Config -> Value

toEncoding :: Config -> Encoding

toJSONList :: [Config] -> Value

toEncodingList :: [Config] -> Encoding

omitField :: Config -> Bool

Monoid Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Semigroup Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Show Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Eq Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Pretty Config Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

pretty :: Config -> Doc ann

prettyList :: [Config] -> Doc ann

data TracingMode Source #

How to trace.

Since: 1.6.0

Instances

Instances details
FromJSON TracingMode Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

parseJSON :: Value -> Parser TracingMode

parseJSONList :: Value -> Parser [TracingMode]

omittedField :: Maybe TracingMode

ToJSON TracingMode Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

toJSON :: TracingMode -> Value

toEncoding :: TracingMode -> Encoding

toJSONList :: [TracingMode] -> Value

toEncodingList :: [TracingMode] -> Encoding

omitField :: TracingMode -> Bool

Semigroup TracingMode Source #

More general tracing supersedes less general.

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Show TracingMode Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Eq TracingMode Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Ord TracingMode Source #

We have a linear order of generality, so this instance reflects it: 'smaller' values are more specific. Generality is in the following order, from least to most general:

  1. DetTracing
  2. DoTracing
  3. DoTracingAndBinds

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Pretty TracingMode Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

pretty :: TracingMode -> Doc ann

prettyList :: [TracingMode] -> Doc ann

data LogLevel Source #

What logging level we want to use.

Since: 1.6.0

Constructors

LogInfo 
LogDebug 

Instances

Instances details
FromJSON LogLevel Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

parseJSON :: Value -> Parser LogLevel

parseJSONList :: Value -> Parser [LogLevel]

omittedField :: Maybe LogLevel

ToJSON LogLevel Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

toJSON :: LogLevel -> Value

toEncoding :: LogLevel -> Encoding

toJSONList :: [LogLevel] -> Value

toEncodingList :: [LogLevel] -> Encoding

omitField :: LogLevel -> Bool

Semigroup LogLevel Source #

More general logging supersedes less general.

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Show LogLevel Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Eq LogLevel Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Ord LogLevel Source #

We have a linear order of generality, so this instance reflects it: LogDebug is more general than LogInfo.

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Pretty LogLevel Source #

Since: 1.6.0

Instance details

Defined in Plutarch.Internal.Term

Methods

pretty :: LogLevel -> Doc ann

prettyList :: [LogLevel] -> Doc ann

tracingMode :: Config -> Maybe TracingMode Source #

If the config indicates that we want to trace, get its mode.

Since: 1.6.0

logLevel :: Config -> Maybe LogLevel Source #

If the config indicates that we want to trace, get its log level.

Since: 1.6.0

pgetConfig :: (Config -> Term s a) -> Term s a Source #

newtype TermMonad m Source #

Constructors

TermMonad 

Instances

Instances details
Applicative TermMonad Source # 
Instance details

Defined in Plutarch.Internal.Term

Methods

pure :: a -> TermMonad a Source #

(<*>) :: TermMonad (a -> b) -> TermMonad a -> TermMonad b Source #

liftA2 :: (a -> b -> c) -> TermMonad a -> TermMonad b -> TermMonad c Source #

(*>) :: TermMonad a -> TermMonad b -> TermMonad b Source #

(<*) :: TermMonad a -> TermMonad b -> TermMonad a Source #

Functor TermMonad Source # 
Instance details

Defined in Plutarch.Internal.Term

Methods

fmap :: (a -> b) -> TermMonad a -> TermMonad b Source #

(<$) :: a -> TermMonad b -> TermMonad a Source #

Monad TermMonad Source # 
Instance details

Defined in Plutarch.Internal.Term

Methods

(>>=) :: TermMonad a -> (a -> TermMonad b) -> TermMonad b Source #

(>>) :: TermMonad a -> TermMonad b -> TermMonad b Source #

return :: a -> TermMonad a Source #

(#) :: Term s (a :--> b) -> Term s a -> Term s b infixl 8 Source #

High precedence infixl synonym of papp, to be used like function juxtaposition. e.g.:

>>> f # x # y
f x y

(#$) :: Term s (a :--> b) -> Term s a -> Term s b infixr 0 Source #

Low precedence infixr synonym of papp, to be used like $, in combination with #. e.g.:

>>> f # x #$ g # y # z
f x (g y z)