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 #

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.String

Monoid (Term s PByteString) Source # 
Instance details

Defined in Plutarch.ByteString

Monoid (Term s PString) Source # 
Instance details

Defined in Plutarch.String

Monoid (Term s (PUnit :: S -> Type)) Source # 
Instance details

Defined in Plutarch.Unit

Semigroup (Term s PByteString) Source # 
Instance details

Defined in Plutarch.ByteString

Semigroup (Term s PString) Source # 
Instance details

Defined in Plutarch.String

Semigroup (Term s (PUnit :: S -> Type)) Source # 
Instance details

Defined in Plutarch.Unit

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

Defined in Plutarch.Num

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 #

(PNum a, PFractional a) => Fractional (Term s a) Source # 
Instance details

Defined in Plutarch.Rational

Methods

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

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

fromRational :: Rational -> Term s a Source #

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-DaxzFvLNVysDL1hkJ4YFrw" '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 :: 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

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 #

Constructors

RVar Word64 
RLamAbs Word64 RawTerm 
RApply RawTerm [RawTerm] 
RForce RawTerm 
RDelay RawTerm 
RConstant (Some (ValueOf DefaultUni)) 
RBuiltin DefaultFun 
RCompiled UTerm 
RError 
RHoisted HoistedTerm 

Instances

Instances details
Show RawTerm Source # 
Instance details

Defined in Plutarch.Internal.Term

data TermResult Source #

Constructors

TermResult 

Fields

data S Source #

Constructors

SI 

Instances

Instances details
PIsData (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Builtin

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PUnit) -> Term s PUnit Source #

pdataImpl :: forall (s :: S). Term s PUnit -> Term s PData Source #

PEq (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Methods

(#==) :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PBool Source #

PLiftable (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Associated Types

type AsHaskell PUnit Source #

type PlutusRepr PUnit Source #

POrd (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Methods

pmax :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PUnit Source #

pmin :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PUnit Source #

PPartialOrd (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Methods

(#<=) :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PBool Source #

(#<) :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PBool Source #

(#>=) :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PBool Source #

(#>) :: forall (s :: S). Term s PUnit -> Term s PUnit -> Term s PBool Source #

PlutusType (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Methods

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

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

PShow (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

Methods

pshow' :: forall (s :: S). Bool -> Term s PUnit -> Term s PString Source #

Monoid (Term s (PUnit :: S -> Type)) Source # 
Instance details

Defined in Plutarch.Unit

Semigroup (Term s (PUnit :: S -> Type)) Source # 
Instance details

Defined in Plutarch.Unit

type AsHaskell (PUnit :: S -> Type) Source #

@since WIP

Instance details

Defined in Plutarch.Unit

type PlutusRepr (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

type PContravariant' (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

type PCovariant' (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

type PCovariant' (PUnit :: S -> Type)
type PInner (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

type PInner (PUnit :: S -> Type) = PUnit :: S -> Type
type PVariant' (PUnit :: S -> Type) Source # 
Instance details

Defined in Plutarch.Unit

type PVariant' (PUnit :: S -> Type)

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)