plutus-core-1.0.0.1: Language library for Plutus Core
Safe Haskell None
Language Haskell2010

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 :: ( KnownTypeAst ( UniOf val) res, MakeKnown val res) => TypeScheme val '[] res
TypeSchemeArrow :: ( KnownTypeAst ( UniOf val) arg, MakeKnown val arg, ReadKnown 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 #

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.

class (uni `Everywhere` ImplementedKnownTypeAst uni, uni `Everywhere` ImplementedReadKnownIn uni, uni `Everywhere` ImplementedMakeKnownIn uni) => TestTypesFromTheUniverseAreAllKnown uni Source #

An instance of this class not having any constraints ensures that every type (according to Everywhere ) from the universe has 'KnownTypeAst, ReadKnownIn and MakeKnownIn instances.

data Peano Source #

Peano numbers. Normally called Nat , but that is already reserved by base .

Constructors

Z
S Peano

type family ToRuntimeDenotationType val n where ... Source #

Compute the runtime denotation type of a builtin given the type of values and the number of arguments that the builtin takes. A "runtime denotation type" is different from a regular denotation type in that a regular one can have any ReadKnownIn type as an argument and can return any MakeKnownIn type, while in a runtime one only val can appear as the type of an argument, as well as in the result type. This is what we get by calling readKnown over each argument of the denotation and calling makeKnown over its result.

type family ToCostingType n where ... Source #

Compute the costing type for a builtin given the number of arguments that the builtin takes.

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 fromBuiltinRuntimeOptions ) a BuiltinRuntimeOptions .

A BuiltinRuntime contains info that is used during evaluation:

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

All the three are in sync in terms of partial instantiatedness due to RuntimeScheme being a GADT and ToRuntimeDenotationType and ToCostingType operating on the index of that GADT.

noThunksInCosting :: Context -> ToCostingType n -> RuntimeScheme n -> IO ( Maybe ThunkInfo ) Source #

Check whether the given `ToCostingType n` contains thunks. The `RuntimeScheme n` is used to refine n .

data UnliftingMode Source #

Determines how to unlift arguments. The difference is that with UnliftingImmediate unlifting is performed immediately after a builtin gets the argument and so can fail immediately too, while with deferred unlifting all arguments are unlifted upon full saturation, hence no failure can occur until that. The former makes it much harder to specify the behaviour of builtins and so UnliftingDeferred is the preferred mode.

data BuiltinRuntimeOptions n val cost Source #

A BuiltinRuntimeOptions is a precursor to BuiltinRuntime . One gets the latter from the former by choosing the runtime denotation of the builtin (either _broImmediateF for immediate unlifting or _broDeferredF for deferred unlifting, see UnliftingMode for details) and by instantiating _broToExF with a cost model to get the costing function for the builtin.

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
( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Bifunctor Opaque Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bimap :: (a -> b) -> (c -> d) -> Opaque a c -> Opaque b d Source #

first :: (a -> b) -> Opaque a c -> Opaque b c Source #

second :: (b -> c) -> Opaque a b -> Opaque a c Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Bitraversable Opaque Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Opaque a b -> f ( Opaque c d) Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Bifoldable Opaque Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bifold :: Monoid m => Opaque m m -> m Source #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Opaque a b -> m Source #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Opaque a b -> c Source #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Opaque a b -> c Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause ( Opaque val rep) Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Maybe cause -> Opaque val rep -> MakeKnownM cause val Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Monad ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Functor ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fmap :: (a -> b) -> Opaque val a -> Opaque val b Source #

(<$) :: a -> Opaque val b -> Opaque val a Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => MonadFail ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Applicative ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Foldable ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fold :: Monoid m => Opaque val m -> m Source #

foldMap :: Monoid m => (a -> m) -> Opaque val a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Opaque val a -> m Source #

foldr :: (a -> b -> b) -> b -> Opaque val a -> b Source #

foldr' :: (a -> b -> b) -> b -> Opaque val a -> b Source #

foldl :: (b -> a -> b) -> b -> Opaque val a -> b Source #

foldl' :: (b -> a -> b) -> b -> Opaque val a -> b Source #

foldr1 :: (a -> a -> a) -> Opaque val a -> a Source #

foldl1 :: (a -> a -> a) -> Opaque val a -> a Source #

toList :: Opaque val a -> [a] Source #

null :: Opaque val a -> Bool Source #

length :: Opaque val a -> Int Source #

elem :: Eq a => a -> Opaque val a -> Bool Source #

maximum :: Ord a => Opaque val a -> a Source #

minimum :: Ord a => Opaque val a -> a Source #

sum :: Num a => Opaque val a -> a Source #

product :: Num a => Opaque val a -> a Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Traversable ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

traverse :: Applicative f => (a -> f b) -> Opaque val a -> f ( Opaque val b) Source #

sequenceA :: Applicative f => Opaque val (f a) -> f ( Opaque val a) Source #

mapM :: Monad m => (a -> m b) -> Opaque val a -> m ( Opaque val b) Source #

sequence :: Monad m => Opaque val (m a) -> m ( Opaque val a) Source #

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => Alternative ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => MonadPlus ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

( TypeError NoRegularlyAppliedHkVarsMsg :: Constraint ) => MonadIO ( Opaque val) Source #
Instance details

Defined in PlutusCore.Builtin.Polymorphism

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

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

( 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

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

Defined in PlutusCore.Builtin.Polymorphism

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

data TyNameRep (kind :: Type ) Source #

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

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

( 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

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

Defined in PlutusCore.Builtin.Polymorphism

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

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

Defined in PlutusCore.Builtin.Polymorphism

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

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.

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

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) ( BuiltinRuntimeOptions ( Length args) val cost)

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.

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

Get the type of a built-in function.

type family Length xs where ... Source #

Compute the length of a type-level list.

Equations

Length '[] = ' Z
Length (_ ': xs) = ' S ( Length xs)

type family GetArgs a where ... Source #

Chop a function type to get a list of its argument types.

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. We could've easily computed a RuntimeScheme from a TypeScheme but not statically (due to unfolding not working for recursive functions and TypeScheme is recursive, i.e. the conversion can only be a recursive function), and so it would cause us to retain a lot of evaluation-irrelevant stuff in the constructors of TypeScheme , which makes it much harder to read the Core. Technically speaking, we could convert a TypeScheme to a RuntimeScheme statically if we changed the definition of TypeScheme and made it a singleton, but then the conversion function would have to become a class anyway and we'd just replicate what we have here, except in a much more complicated way. It's also more efficient to generate RuntimeScheme s directly, but that shouldn't really matter, -- given that they computed only once and cached afterwards.

Similarly, we could've computed toImmediateF and toDeferredF from a TypeScheme but not statically again, and that would break inlining and basically all the optimization.

Methods

knownMonotype :: TypeScheme val args res Source #

knownMonoruntime :: RuntimeScheme ( Length args) Source #

toImmediateF :: FoldArgs args res -> ToRuntimeDenotationType val ( Length args) Source #

Convert the denotation of a builtin to its runtime counterpart with immediate unlifting.

toDeferredF :: ReadKnownM () ( FoldArgs args res) -> ToRuntimeDenotationType val ( Length args) Source #

Convert the denotation of a builtin to its runtime counterpart with deferred unlifting. The argument is in ReadKnownM , because that's what deferred unlifting amounts to: passing the action returning the builtin application around until full saturation, which is when the action actually gets run.

Instances

Instances details
(res ~ res', KnownTypeAst ( UniOf val) res, MakeKnown 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

( KnownTypeAst ( UniOf val) arg, MakeKnown val arg, ReadKnown 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

class KnownMonotype val args res a => 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.

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

( 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

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 -> ToCostingType ( Length 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

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

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

data TyNameRep (kind :: Type ) Source #

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

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

( 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

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

Defined in PlutusCore.Builtin.Polymorphism

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

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

Defined in PlutusCore.Builtin.Polymorphism

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

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.

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.

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

(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

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

Defined in PlutusCore.Builtin.KnownTypeAst

Methods

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

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

Defined in PlutusCore.Default.Universe

KnownTypeAst DefaultUni Int Source #
Instance details

Defined in PlutusCore.Default.Universe

KnownTypeAst DefaultUni Int64 Source #
Instance details

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Default.Universe

KnownTypeAst DefaultUni Void Source #
Instance details

Defined in PlutusCore.Examples.Builtins

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

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Builtin.KnownTypeAst

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

Defined in PlutusCore.Builtin.KnownTypeAst

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

Defined in PlutusCore.Examples.Builtins

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

Defined in PlutusCore.Default.Universe

( 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

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 #

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 ReadKnownIn and MakeKnownIn by means of being included in uni ".

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

A constraint for " a is a ReadKnownIn and MakeKnownIn by means of being included in UniOf term ".

readKnownConstant :: forall val a cause. KnownBuiltinType val a => Maybe cause -> val -> ReadKnownM cause a Source #

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

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

Minimal complete definition

Nothing

Methods

makeKnown :: Maybe cause -> a -> MakeKnownM cause val Source #

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

Instances

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

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Int64 Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Data Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Bool Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term () Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> () -> MakeKnownM cause term Source #

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Text Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term ByteString Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Integer Source #
Instance details

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Examples.Builtins

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

Defined in PlutusCore.Builtin.KnownType

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

Defined in PlutusCore.Builtin.KnownType

( HasConstantIn DefaultUni term, Contains DefaultUni [a]) => MakeKnownIn DefaultUni term [a] Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> [a] -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Maybe cause -> Opaque val rep -> MakeKnownM cause val Source #

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

Defined in PlutusCore.Builtin.KnownType

( HasConstantIn DefaultUni term, Contains DefaultUni (a, b)) => MakeKnownIn DefaultUni term (a, b) Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> (a, b) -> MakeKnownM cause term Source #

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

Minimal complete definition

Nothing

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause a Source #

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

Instances

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

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Int64 Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Data Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Bool Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term () Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause () Source #

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Text Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term ByteString Source #
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Integer Source #
Instance details

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Examples.Builtins

( TypeError (' Text "\8216Emitter\8217 cannot appear in the type of an argument") :: Constraint , uni ~ UniOf val) => ReadKnownIn uni val ( Emitter a) Source #
Instance details

Defined in PlutusCore.Builtin.KnownType

( TypeError (' Text "\8216EvaluationResult\8217 cannot appear in the type of an argument") :: Constraint , uni ~ UniOf val) => ReadKnownIn uni val ( EvaluationResult a) Source #
Instance details

Defined in PlutusCore.Builtin.KnownType

( HasConstantIn DefaultUni term, Contains DefaultUni [a]) => ReadKnownIn DefaultUni term [a] Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause [a] Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause ( Opaque val rep) Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause ( SomeConstant uni rep) Source #

( HasConstantIn DefaultUni term, Contains DefaultUni (a, b)) => ReadKnownIn DefaultUni term (a, b) Source #
Instance details

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause (a, b) Source #

makeKnownOrFail :: MakeKnownIn uni val a => a -> EvaluationResult val Source #

Same as makeKnown , but allows for neither emitting nor storing the cause of a failure.

readKnownSelf :: ( ReadKnown 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.

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 .

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

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

Defined in PlutusCore.Builtin.KnownKind

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 HasConstant term where Source #

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

Methods

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

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

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

Wrap a Haskell value as a term .

Instances

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

Defined in PlutusCore.Builtin.Polymorphism

HasConstant ( CkValue uni fun) Source #
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

HasConstant ( CekValue uni fun) Source #
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

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

Defined in UntypedPlutusCore.Core.Type

Methods

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

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

HasConstant ( Term TyName Name uni fun ()) Source #
Instance details

Defined in PlutusCore.Builtin.HasConstant

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

Defined in PlutusIR.Core.Type

Methods

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

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

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 .