plutus-core-0.1.0.0: Language library for Plutus Core
Safe HaskellNone
LanguageHaskell2010

PlutusCore.Builtin

Description

Reexports from modules from the Builtin folder.

Synopsis

Documentation

data TypeScheme val (args :: [Type]) res where Source #

Type schemes of primitive operations. as is a list of types of arguments, r is the resulting type. E.g. Text -> Bool -> Integer is encoded as TypeScheme val [Text, Bool] Integer.

Constructors

TypeSchemeResult :: KnownType val res => TypeScheme val '[] res 
TypeSchemeArrow :: KnownType val arg => TypeScheme val args res -> TypeScheme val (arg ': args) res infixr 9 
TypeSchemeAll :: (KnownSymbol text, KnownNat uniq, KnownKind kind) => Proxy '(text, uniq, kind) -> TypeScheme val args res -> TypeScheme val args res 

argProxy :: TypeScheme val (arg ': args) res -> Proxy arg Source #

type family FoldArgs args res where ... Source #

Turn a list of Haskell types args into a functional type ending in res.

>>> :set -XDataKinds
>>> :kind! FoldArgs [Text, Bool] Integer
FoldArgs [Text, Bool] Integer :: *
= Text -> Bool -> Integer

Equations

FoldArgs '[] res = res 
FoldArgs (arg ': args) res = arg -> FoldArgs args res 

type family FoldArgsEx args where ... Source #

Calculates the parameters of the costing function for a builtin.

Equations

FoldArgsEx '[] = ExBudget 
FoldArgsEx (arg ': args) = ExMemory -> FoldArgsEx args 

typeSchemeToType :: TypeScheme val args res -> Type TyName (UniOf val) () Source #

Convert a TypeScheme to the corresponding Type. Basically, a map from the PHOAS representation to the FOAS one.

data RuntimeScheme val (args :: [Type]) res where Source #

Same as TypeScheme except this one doesn't contain any evaluation-irrelevant types stuff.

Constructors

RuntimeSchemeResult :: KnownTypeIn (UniOf val) val res => RuntimeScheme val '[] res 
RuntimeSchemeArrow :: KnownTypeIn (UniOf val) val arg => RuntimeScheme val args res -> RuntimeScheme val (arg ': args) res 
RuntimeSchemeAll :: RuntimeScheme val args res -> RuntimeScheme val args res 

data BuiltinRuntime val Source #

A BuiltinRuntime represents a possibly partial builtin application. We get an initial BuiltinRuntime representing an empty builtin application (i.e. just the builtin with no arguments) by instantiating (via toBuiltinRuntime) a BuiltinMeaning.

A BuiltinRuntime contains info that is used during evaluation:

  1. the TypeScheme of the uninstantiated part of the builtin. I.e. initially it's the type scheme of the whole builtin, but applying or type-instantiating the builtin peels off the corresponding constructor from the type scheme
  2. the (possibly partially instantiated) denotation
  3. the (possibly partially instantiated) costing function

All the three are in sync in terms of partial instantiatedness due to TypeScheme being a GADT and FoldArgs and FoldArgsEx operating on the index of that GADT.

Constructors

forall args res. BuiltinRuntime (RuntimeScheme val args res) ~(FoldArgs args res) ~(FoldArgsEx args) 

Instances

Instances details
Show (BuiltinRuntime (CkValue uni fun)) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Show (BuiltinRuntime (CekValue uni fun)) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

newtype BuiltinsRuntime fun val Source #

A BuiltinRuntime for each builtin from a set of builtins.

Constructors

BuiltinsRuntime 

typeSchemeToRuntimeScheme :: TypeScheme val args res -> RuntimeScheme val args res Source #

Convert a TypeScheme to a RuntimeScheme.

toBuiltinRuntime :: cost -> BuiltinMeaning val cost -> BuiltinRuntime val Source #

Instantiate a BuiltinMeaning given denotations of built-in functions and a cost model.

toBuiltinsRuntime :: (cost ~ CostingPart uni fun, HasConstantIn uni val, ToBuiltinMeaning uni fun) => cost -> BuiltinsRuntime fun val Source #

Calculate runtime info for all built-in functions given denotations of builtins and a cost model.

lookupBuiltin :: (MonadError (ErrorWithCause err cause) m, AsMachineError err fun, Ix fun) => fun -> BuiltinsRuntime fun val -> m (BuiltinRuntime val) Source #

Look up the runtime info of a built-in function during evaluation.

newtype Opaque val (rep :: Type) Source #

The denotation of a term whose PLC type is encoded in rep (for example a type variable or an application of a type variable). I.e. the denotation of such a term is the term itself. This is because we have parametricity in Haskell, so we can't inspect a value whose type is, say, a bound variable, so we never need to convert such a term from Plutus Core to Haskell and back and instead can keep it intact.

Constructors

Opaque 

Fields

Instances

Instances details
uni ~ UniOf val => KnownTypeIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Opaque val rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (Opaque val rep) Source #

KnownTypeAst uni rep => KnownTypeAst uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (Opaque val rep) :: [Hole] Source #

type ToBinds (Opaque val rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (Opaque val rep) -> Type0 TyName uni () Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Bounded (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

minBound :: Opaque val rep Source #

maxBound :: Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Enum (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

succ :: Opaque val rep -> Opaque val rep Source #

pred :: Opaque val rep -> Opaque val rep Source #

toEnum :: Int -> Opaque val rep Source #

fromEnum :: Opaque val rep -> Int Source #

enumFrom :: Opaque val rep -> [Opaque val rep] Source #

enumFromThen :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromTo :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromThenTo :: Opaque val rep -> Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Eq (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(==) :: Opaque val rep -> Opaque val rep -> Bool Source #

(/=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Integral (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

quot :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

rem :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

div :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mod :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

quotRem :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

divMod :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

toInteger :: Opaque val rep -> Integer Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Num (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(+) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(-) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(*) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

negate :: Opaque val rep -> Opaque val rep Source #

abs :: Opaque val rep -> Opaque val rep Source #

signum :: Opaque val rep -> Opaque val rep Source #

fromInteger :: Integer -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ord (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

compare :: Opaque val rep -> Opaque val rep -> Ordering Source #

(<) :: Opaque val rep -> Opaque val rep -> Bool Source #

(<=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>=) :: Opaque val rep -> Opaque val rep -> Bool Source #

max :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

min :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Real (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

toRational :: Opaque val rep -> Rational Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ix (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

range :: (Opaque val rep, Opaque val rep) -> [Opaque val rep] Source #

index :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

unsafeIndex :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

inRange :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Bool Source #

rangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

unsafeRangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Semigroup (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(<>) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

sconcat :: NonEmpty (Opaque val rep) -> Opaque val rep Source #

stimes :: Integral b => b -> Opaque val rep -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Monoid (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

mempty :: Opaque val rep Source #

mappend :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mconcat :: [Opaque val rep] -> Opaque val rep Source #

Pretty val => Pretty (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

pretty :: Opaque val rep -> Doc ann Source #

prettyList :: [Opaque val rep] -> Doc ann Source #

FromConstant val => FromConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> Opaque val rep Source #

AsConstant val => AsConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Opaque val rep -> m (Some (ValueOf (UniOf (Opaque val rep)))) Source #

type ToHoles (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (Opaque val rep :: Type) = '[RepHole rep :: Hole]
type ToBinds (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (Opaque val rep :: Type) = ToBinds rep
type UniOf (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type UniOf (Opaque val rep) = UniOf val

newtype SomeConstant uni (rep :: Type) Source #

For unlifting from the Constant constructor when the stored value is of a monomorphic built-in type

The rep parameter specifies how the type looks on the PLC side (i.e. just like with Opaque val rep).

Constructors

SomeConstant 

Fields

Instances

Instances details
HasConstantIn uni val => KnownTypeIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> SomeConstant uni rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (SomeConstant uni rep) Source #

KnownTypeAst uni rep => KnownTypeAst uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (SomeConstant uni rep) :: [Hole] Source #

type ToBinds (SomeConstant uni rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (SomeConstant uni rep) -> Type0 TyName uni () Source #

type ToHoles (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (SomeConstant uni rep :: Type) = '[RepHole rep :: Hole]
type ToBinds (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (SomeConstant uni rep :: Type) = ToBinds rep

data TyNameRep (kind :: Type) Source #

Representation of a type variable: its name and unique and an implicit kind.

Constructors

TyNameRep Symbol Nat 

Instances

Instances details
KnownMonotype val args res a => KnownPolytype ('[] :: [Some TyNameRep]) val args res (a :: k) Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy '[] -> TypeScheme val args res Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res a) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res (a :: k) Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy ('Some ('TyNameRep name uniq) ': binds) -> TypeScheme val args res Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

data family TyVarRep (name :: TyNameRep kind) :: kind Source #

Representation of an intrinsically-kinded type variable: a name.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyVarRep name) :: [Hole] Source #

type ToBinds (TyVarRep name) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyVarRep name) -> Type TyName uni () Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

type ToHoles (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyVarRep name :: a) = '[] :: [Hole]
type ToBinds (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyVarRep name :: a) = '['Some name]

data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #

Representation of an intrinsically-kinded type application: a function and an argument.

Instances

Instances details
(KnownTypeAst uni fun, KnownTypeAst uni arg) => KnownTypeAst uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyAppRep fun arg) :: [Hole] Source #

type ToBinds (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyAppRep fun arg) -> Type TyName uni () Source #

type ToHoles (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyAppRep fun arg :: a) = '[RepHole fun :: Hole, RepHole arg :: Hole]
type ToBinds (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyAppRep fun arg :: a) = Merge (ToBinds fun) (ToBinds arg)

data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #

Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst uni a) => KnownTypeAst uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyForallRep name a) :: [Hole] Source #

type ToBinds (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyForallRep name a) -> Type0 TyName uni () Source #

type ToHoles (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyForallRep name a :: Type) = '[RepHole a :: Hole]
type ToBinds (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyForallRep name a :: Type)

data BuiltinMeaning val cost Source #

The meaning of a built-in function consists of its type represented as a TypeScheme, its Haskell denotation and a costing function (both in uninstantiated form).

The TypeScheme of a built-in function is used for

  1. computing the PLC type of the function to be used during type checking
  2. checking equality of the expected type of an argument of a builtin and the actual one during evaluation, so that we can avoid unsafe-coercing

A costing function for a built-in function is computed from a cost model for all built-in functions from a certain set, hence the cost parameter.

Constructors

forall args res. BuiltinMeaning (TypeScheme val args res) (FoldArgs args res) (cost -> FoldArgsEx args) 

class (Bounded fun, Enum fun, Ix fun) => ToBuiltinMeaning uni fun where Source #

A type class for "each function from a set of built-in functions has a BuiltinMeaning".

Associated Types

type CostingPart uni fun Source #

The cost part of BuiltinMeaning.

Methods

toBuiltinMeaning :: HasConstantIn uni val => fun -> BuiltinMeaning val (CostingPart uni fun) Source #

Get the BuiltinMeaning of a built-in function.

Instances

Instances details
uni ~ DefaultUni => ToBuiltinMeaning uni DefaultFun Source # 
Instance details

Defined in PlutusCore.Default.Builtins

Associated Types

type CostingPart uni DefaultFun Source #

uni ~ DefaultUni => ToBuiltinMeaning uni ExtensionFun Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type CostingPart uni ExtensionFun Source #

(ToBuiltinMeaning uni fun1, ToBuiltinMeaning uni fun2) => ToBuiltinMeaning uni (Either fun1 fun2) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type CostingPart uni (Either fun1 fun2) Source #

Methods

toBuiltinMeaning :: HasConstantIn uni val => Either fun1 fun2 -> BuiltinMeaning val (CostingPart uni (Either fun1 fun2)) Source #

typeOfBuiltinFunction :: ToBuiltinMeaning uni fun => fun -> Type TyName uni () Source #

Get the type of a built-in function.

type family GetArgs a :: [Type] where ... Source #

Equations

GetArgs (a -> b) = a ': GetArgs b 
GetArgs _ = '[] 

class KnownMonotype val args res a | args res -> a, a -> res where Source #

A class that allows us to derive a monotype for a builtin.

Methods

knownMonotype :: TypeScheme val args res Source #

Instances

Instances details
(res ~ res', KnownType val res) => KnownMonotype val ('[] :: [Type]) res (res' :: Type) Source #

Once we've run out of term-level arguments, we return a TypeSchemeResult.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownMonotype :: TypeScheme val '[] res Source #

(KnownType val arg, KnownMonotype val args res a) => KnownMonotype val (arg ': args) res (arg -> a :: Type) Source #

Every term-level argument becomes as TypeSchemeArrow.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownMonotype :: TypeScheme val (arg ': args) res Source #

class KnownPolytype (binds :: [Some TyNameRep]) val args res a | args res -> a, a -> res where Source #

A class that allows us to derive a polytype for a builtin.

Methods

knownPolytype :: Proxy binds -> TypeScheme val args res Source #

Instances

Instances details
KnownMonotype val args res a => KnownPolytype ('[] :: [Some TyNameRep]) val args res (a :: k) Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy '[] -> TypeScheme val args res Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res a) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res (a :: k) Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy ('Some ('TyNameRep name uniq) ': binds) -> TypeScheme val args res Source #

makeBuiltinMeaning :: forall a val cost binds args res j. (binds ~ ToBinds a, args ~ GetArgs a, a ~ FoldArgs args res, ElaborateFromTo 0 j val a, KnownPolytype binds val args res a) => a -> (cost -> FoldArgsEx args) -> BuiltinMeaning val cost Source #

Construct the meaning for a built-in function by automatically deriving its TypeScheme, given

  1. the denotation of the builtin
  2. an uninstantiated costing function

data TyNameRep (kind :: Type) Source #

Representation of a type variable: its name and unique and an implicit kind.

Constructors

TyNameRep Symbol Nat 

Instances

Instances details
KnownMonotype val args res a => KnownPolytype ('[] :: [Some TyNameRep]) val args res (a :: k) Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy '[] -> TypeScheme val args res Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res a) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res (a :: k) Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy ('Some ('TyNameRep name uniq) ': binds) -> TypeScheme val args res Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

data family TyVarRep (name :: TyNameRep kind) :: kind Source #

Representation of an intrinsically-kinded type variable: a name.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyVarRep name) :: [Hole] Source #

type ToBinds (TyVarRep name) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyVarRep name) -> Type TyName uni () Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

type ToHoles (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyVarRep name :: a) = '[] :: [Hole]
type ToBinds (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyVarRep name :: a) = '['Some name]

data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #

Representation of an intrinsically-kinded type application: a function and an argument.

Instances

Instances details
(KnownTypeAst uni fun, KnownTypeAst uni arg) => KnownTypeAst uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyAppRep fun arg) :: [Hole] Source #

type ToBinds (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyAppRep fun arg) -> Type TyName uni () Source #

type ToHoles (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyAppRep fun arg :: a) = '[RepHole fun :: Hole, RepHole arg :: Hole]
type ToBinds (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyAppRep fun arg :: a) = Merge (ToBinds fun) (ToBinds arg)

data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #

Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst uni a) => KnownTypeAst uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyForallRep name a) :: [Hole] Source #

type ToBinds (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyForallRep name a) -> Type0 TyName uni () Source #

type ToHoles (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyForallRep name a :: Type) = '[RepHole a :: Hole]
type ToBinds (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyForallRep name a :: Type)

data Hole Source #

The kind of holes.

data family RepHole x Source #

A hole in the Rep context.

data family TypeHole a Source #

A hole in the Type context.

type KnownBuiltinTypeAst uni a = KnownTypeAst uni (ElaborateBuiltin a) Source #

A constraint for "a is a KnownTypeAst by means of being included in uni".

class KnownTypeAst uni x where Source #

Minimal complete definition

Nothing

Associated Types

type ToHoles x :: [Hole] Source #

Return every part of the type that can be a to-be-instantiated type variable. For example, in Integer there's no such types and in (a, b) it's the two arguments (a and b) and the same applies to a -> b (to mention a type that is not built-in).

type ToHoles x = ToHoles (ElaborateBuiltin x)

type ToBinds x :: [Some TyNameRep] Source #

Collect all unique variables (a variable consists of a textual name, a unique and a kind) in an a.

type ToBinds x = ToBinds (ElaborateBuiltin x)

Methods

toTypeAst :: proxy x -> Type TyName uni () Source #

The type representing a used on the PLC side.

default toTypeAst :: KnownBuiltinTypeAst uni x => proxy x -> Type TyName uni () Source #

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyVarRep name) :: [Hole] Source #

type ToBinds (TyVarRep name) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyVarRep name) -> Type TyName uni () Source #

(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst uni a) => KnownTypeAst uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyForallRep name a) :: [Hole] Source #

type ToBinds (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyForallRep name a) -> Type0 TyName uni () Source #

(KnownTypeAst uni fun, KnownTypeAst uni arg) => KnownTypeAst uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyAppRep fun arg) :: [Hole] Source #

type ToBinds (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyAppRep fun arg) -> Type TyName uni () Source #

KnownBuiltinTypeAst DefaultUni Bool => KnownTypeAst DefaultUni Bool Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Bool :: [Hole] Source #

type ToBinds Bool :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Bool -> Type TyName DefaultUni () Source #

KnownTypeAst DefaultUni Int Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Int :: [Hole] Source #

type ToBinds Int :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Int -> Type TyName DefaultUni () Source #

KnownBuiltinTypeAst DefaultUni Integer => KnownTypeAst DefaultUni Integer Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Integer :: [Hole] Source #

type ToBinds Integer :: [Some TyNameRep] Source #

KnownBuiltinTypeAst DefaultUni () => KnownTypeAst DefaultUni () Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles () :: [Hole] Source #

type ToBinds () :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy () -> Type TyName DefaultUni () Source #

KnownBuiltinTypeAst DefaultUni ByteString => KnownTypeAst DefaultUni ByteString Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles ByteString :: [Hole] Source #

type ToBinds ByteString :: [Some TyNameRep] Source #

KnownBuiltinTypeAst DefaultUni Text => KnownTypeAst DefaultUni Text Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Text :: [Hole] Source #

type ToBinds Text :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Text -> Type TyName DefaultUni () Source #

KnownTypeAst DefaultUni Void Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type ToHoles Void :: [Hole] Source #

type ToBinds Void :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Void -> Type TyName DefaultUni () Source #

KnownBuiltinTypeAst DefaultUni Data => KnownTypeAst DefaultUni Data Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Data :: [Hole] Source #

type ToBinds Data :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Data -> Type TyName DefaultUni () Source #

KnownTypeAst uni a => KnownTypeAst uni (Emitter a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (Emitter a) :: [Hole] Source #

type ToBinds (Emitter a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (Emitter a) -> Type0 TyName uni () Source #

KnownTypeAst uni a => KnownTypeAst uni (EvaluationResult a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (EvaluationResult a) :: [Hole] Source #

type ToBinds (EvaluationResult a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (EvaluationResult a) -> Type0 TyName uni () Source #

KnownTypeAst uni a => KnownTypeAst uni (PlcListRep a :: Type) Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Associated Types

type ToHoles (PlcListRep a) :: [Hole] Source #

type ToBinds (PlcListRep a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (PlcListRep a) -> Type0 TyName uni () Source #

KnownBuiltinTypeAst DefaultUni [a] => KnownTypeAst DefaultUni ([a] :: Type) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles [a] :: [Hole] Source #

type ToBinds [a] :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy [a] -> Type0 TyName DefaultUni () Source #

(KnownTypeAst uni a, KnownTypeAst uni b) => KnownTypeAst uni (a -> b :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (a -> b) :: [Hole] Source #

type ToBinds (a -> b) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (a -> b) -> Type0 TyName uni () Source #

KnownTypeAst uni rep => KnownTypeAst uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (Opaque val rep) :: [Hole] Source #

type ToBinds (Opaque val rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (Opaque val rep) -> Type0 TyName uni () Source #

KnownTypeAst uni rep => KnownTypeAst uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (SomeConstant uni rep) :: [Hole] Source #

type ToBinds (SomeConstant uni rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (SomeConstant uni rep) -> Type0 TyName uni () Source #

KnownBuiltinTypeAst DefaultUni (a, b) => KnownTypeAst DefaultUni ((a, b) :: Type) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles (a, b) :: [Hole] Source #

type ToBinds (a, b) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (a, b) -> Type0 TyName DefaultUni () Source #

type family Merge xs ys :: [a] where ... Source #

Delete all elements appearing in the first list from the second one and concatenate the lists.

Equations

Merge '[] ys = ys 
Merge (x ': xs) ys = x ': Delete x (Merge xs ys) 

type KnownBuiltinTypeIn uni val a = (HasConstantIn uni val, GShow uni, GEq uni, uni `Contains` a) Source #

A constraint for "a is a KnownType by means of being included in uni".

type KnownBuiltinType val a = KnownBuiltinTypeIn (UniOf val) val a Source #

A constraint for "a is a KnownType by means of being included in UniOf term".

readKnownConstant :: forall val a err cause. (AsUnliftingError err, KnownBuiltinType val a) => Maybe cause -> val -> Either (ErrorWithCause err cause) a Source #

Convert a constant embedded into a PLC term to the corresponding Haskell value.

class uni ~ UniOf val => KnownTypeIn uni val a where Source #

Haskell types known to exist on the PLC side. Both the methods take a Maybe cause argument to report the cause of a potential failure. cause is different to term to support evaluators that distinguish between terms and values (makeKnown normally constructs a value, but it's convenient to report the cause of a failure as a term). Note that an evaluator might require the cause to be computed lazily for best performance on the happy path and Maybe ensures that even if we somehow force the argument, the cause stored in it is not forced due to Maybe being a lazy data type. Note that KnownTypeAst is not a superclass of KnownTypeIn. This is due to the fact that polymorphic built-in types are only liftable/unliftable when they're fully monomorphized, while toTypeAst works for polymorphic built-in types that have type variables in them, and so the constraints are completely different in the two cases and we keep the two classes apart (there doesn't seem to be any cons to that).

Minimal complete definition

Nothing

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> a -> m val Source #

Convert a Haskell value to the corresponding PLC val. The inverse of readKnown.

default makeKnown :: (MonadError (ErrorWithCause err cause) m, KnownBuiltinType val a) => (Text -> m ()) -> Maybe cause -> a -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) a Source #

Convert a PLC val to the corresponding Haskell value. The inverse of makeKnown.

default readKnown :: (AsUnliftingError err, KnownBuiltinType val a) => Maybe cause -> val -> Either (ErrorWithCause err cause) a Source #

Instances

Instances details
HasConstantIn DefaultUni term => KnownTypeIn DefaultUni term Int Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Int -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Int Source #

KnownBuiltinTypeIn DefaultUni term Data => KnownTypeIn DefaultUni term Data Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Data -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Data Source #

KnownBuiltinTypeIn DefaultUni term Bool => KnownTypeIn DefaultUni term Bool Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Bool -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Bool Source #

KnownBuiltinTypeIn DefaultUni term () => KnownTypeIn DefaultUni term () Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> () -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) () Source #

KnownBuiltinTypeIn DefaultUni term Text => KnownTypeIn DefaultUni term Text Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Text -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Text Source #

KnownBuiltinTypeIn DefaultUni term ByteString => KnownTypeIn DefaultUni term ByteString Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> ByteString -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) ByteString Source #

KnownBuiltinTypeIn DefaultUni term Integer => KnownTypeIn DefaultUni term Integer Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Integer -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Integer Source #

UniOf term ~ DefaultUni => KnownTypeIn DefaultUni term Void Source # 
Instance details

Defined in PlutusCore.Examples.Builtins

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Void -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) Void Source #

KnownTypeIn uni val a => KnownTypeIn uni val (Emitter a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Emitter a -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (Emitter a) Source #

KnownTypeIn uni val a => KnownTypeIn uni val (EvaluationResult a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> EvaluationResult a -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (EvaluationResult a) Source #

KnownBuiltinTypeIn DefaultUni term [a] => KnownTypeIn DefaultUni term [a] Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> [a] -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) [a] Source #

uni ~ UniOf val => KnownTypeIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Opaque val rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (Opaque val rep) Source #

HasConstantIn uni val => KnownTypeIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> SomeConstant uni rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (SomeConstant uni rep) Source #

KnownBuiltinTypeIn DefaultUni term (a, b) => KnownTypeIn DefaultUni term (a, b) Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> (a, b) -> m term Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> term -> Either (ErrorWithCause err cause) (a, b) Source #

type KnownType val a = (KnownTypeAst (UniOf val) a, KnownTypeIn (UniOf val) val a) Source #

Haskell types known to exist on the PLC side. See KnownTypeIn.

class uni `Everywhere` ImplementedKnownBuiltinTypeIn uni => TestTypesFromTheUniverseAreAllKnown uni Source #

An instance of this class not having any constraints ensures that every type (according to Everywhere) from the universe has a KnownTypeIn instance.

Instances

Instances details
TestTypesFromTheUniverseAreAllKnown DefaultUni Source # 
Instance details

Defined in PlutusCore.Default.Universe

readKnownSelf :: (KnownType val a, AsUnliftingError err, AsEvaluationFailure err) => val -> Either (ErrorWithCause err val) a Source #

Same as readKnown, but the cause of a potential failure is the provided term itself.

makeKnownOrFail :: (KnownType val a, MonadError err m, AsEvaluationFailure err) => a -> m val Source #

Same as makeKnown, but allows for neither emitting nor storing the cause of a failure. For example the monad can be simply EvaluationResult.

data SingKind k where Source #

The type of singletonized Haskell kinds representing Plutus kinds. Indexing by a Haskell kind allows us to avoid an error call in the ToKind instance of DefaultUni and not worry about proxies in the type of knownKind.

Constructors

SingType :: SingKind Type 
SingKindArrow :: SingKind k -> SingKind l -> SingKind (k -> l) 

class KnownKind k where Source #

For reifying Haskell kinds representing Plutus kinds at the term level.

Instances

Instances details
rep ~ 'LiftedRep => KnownKind (TYPE rep) Source #

Plutus only supports lifted types, hence the equality constraint.

Instance details

Defined in PlutusCore.Builtin.KnownKind

Methods

knownKind :: SingKind (TYPE rep) Source #

(KnownKind dom, KnownKind cod) => KnownKind (dom -> cod) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownKind

Methods

knownKind :: SingKind (dom -> cod) Source #

class ToKind (uni :: Type -> Type) where Source #

For computing the Plutus kind of a built-in type. See kindOfBuiltinType.

Methods

toSingKind :: uni (Esc (a :: k)) -> SingKind k Source #

Reify the kind of a type from the universe at the term level.

Instances

Instances details
ToKind DefaultUni Source # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

toSingKind :: forall k (a :: k). DefaultUni (Esc a) -> SingKind k Source #

demoteKind :: SingKind k -> Kind () Source #

Convert a reified Haskell kind to a Plutus kind.

kindOfBuiltinType :: ToKind uni => uni (Esc a) -> Kind () Source #

Compute the kind of a type from a universe.

throwNotAConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> m r Source #

Throw an UnliftingError saying that the received argument is not a constant.

class AsConstant term where Source #

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> term -> m (Some (ValueOf (UniOf term))) Source #

Unlift from the Constant constructor throwing an UnliftingError if the provided term is not a Constant.

Instances

Instances details
AsConstant val => AsConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Opaque val rep -> m (Some (ValueOf (UniOf (Opaque val rep)))) Source #

AsConstant (CkValue uni fun) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> CkValue uni fun -> m (Some (ValueOf (UniOf (CkValue uni fun)))) Source #

AsConstant (CekValue uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> CekValue uni fun -> m (Some (ValueOf (UniOf (CekValue uni fun)))) Source #

AsConstant (Term name uni fun ann) Source # 
Instance details

Defined in UntypedPlutusCore.Core.Type

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Term name uni fun ann -> m (Some (ValueOf (UniOf (Term name uni fun ann)))) Source #

AsConstant (Term TyName Name uni fun ann) Source # 
Instance details

Defined in PlutusCore.Builtin.HasConstant

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Term TyName Name uni fun ann -> m (Some (ValueOf (UniOf (Term TyName Name uni fun ann)))) Source #

AsConstant (Term tyname name uni fun ann) Source # 
Instance details

Defined in PlutusIR.Core.Type

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Term tyname name uni fun ann -> m (Some (ValueOf (UniOf (Term tyname name uni fun ann)))) Source #

class FromConstant term where Source #

Methods

fromConstant :: Some (ValueOf (UniOf term)) -> term Source #

Wrap a Haskell value as a term.

Instances

Instances details
FromConstant val => FromConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> Opaque val rep Source #

FromConstant (CkValue uni fun) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Methods

fromConstant :: Some (ValueOf (UniOf (CkValue uni fun))) -> CkValue uni fun Source #

FromConstant (CekValue uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

fromConstant :: Some (ValueOf (UniOf (CekValue uni fun))) -> CekValue uni fun Source #

FromConstant (Term name uni fun ()) Source # 
Instance details

Defined in UntypedPlutusCore.Core.Type

Methods

fromConstant :: Some (ValueOf (UniOf (Term name uni fun ()))) -> Term name uni fun () Source #

FromConstant (Term tyname name uni fun ()) Source # 
Instance details

Defined in PlutusCore.Builtin.HasConstant

Methods

fromConstant :: Some (ValueOf (UniOf (Term tyname name uni fun ()))) -> Term tyname name uni fun () Source #

FromConstant (Term tyname name uni fun ()) Source # 
Instance details

Defined in PlutusIR.Core.Type

Methods

fromConstant :: Some (ValueOf (UniOf (Term tyname name uni fun ()))) -> Term tyname name uni fun () Source #

type HasConstant term = (AsConstant term, FromConstant term) Source #

Ensures that term has a Constant-like constructor to lift values to and unlift values from.

AsConstant and FromConstant are separate, because we need only one instance of AsConstant per Term-like type and FromConstant requires as many instances as there are different kinds of annotations (we're mostly interested in ExMemory and ()). Originally we had a single type class but it proved to be less efficient than having two of them.

type HasConstantIn uni term = (UniOf term ~ uni, HasConstant term) Source #

Ensures that term has a Constant-like constructor to lift values to and unlift values from and connects term and its uni.