plutus-core-1.0.0.1: 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 :: (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.

Instances

Instances details
TestTypesFromTheUniverseAreAllKnown DefaultUni Source # 
Instance details

Defined in PlutusCore.Default.Universe

data Peano Source #

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

Constructors

Z 
S Peano 

data RuntimeScheme n where Source #

Same as TypeScheme except this one doesn't contain any evaluation-irrelevant types stuff. n represents the number of term-level arguments that a builtin takes.

Instances

Instances details
Eq (RuntimeScheme n) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Show (RuntimeScheme n) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

NFData (RuntimeScheme n) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

rnf :: RuntimeScheme n -> () Source #

NoThunks (RuntimeScheme n) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

noThunks :: Context -> RuntimeScheme n -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> RuntimeScheme n -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy (RuntimeScheme n) -> String

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.

Equations

ToRuntimeDenotationType val 'Z = MakeKnownM () val 
ToRuntimeDenotationType val ('S n) = val -> ReadKnownM () (ToRuntimeDenotationType val n) 

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.

Constructors

forall n. BuiltinRuntime (RuntimeScheme n) ~(ToRuntimeDenotationType val n) (ToCostingType n) 

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

NFData (BuiltinRuntime val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

rnf :: BuiltinRuntime val -> () Source #

NoThunks (BuiltinRuntime val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

noThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> BuiltinRuntime val -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy (BuiltinRuntime val) -> String

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.

newtype BuiltinsRuntime fun val Source #

A BuiltinRuntime for each builtin from a set of builtins.

Constructors

BuiltinsRuntime 

Instances

Instances details
NFData fun => NFData (BuiltinsRuntime fun val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

rnf :: BuiltinsRuntime fun val -> () Source #

NoThunks (BuiltinsRuntime fun val) Source # 
Instance details

Defined in PlutusCore.Builtin.Runtime

Methods

noThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo)

wNoThunks :: Context -> BuiltinsRuntime fun val -> IO (Maybe ThunkInfo)

showTypeOf :: Proxy (BuiltinsRuntime fun val) -> String

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) => 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 #

(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 #

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

Methods

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

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

return :: a -> Opaque val a Source #

(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

Methods

fail :: String -> Opaque val a Source #

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

pure :: a -> Opaque val a Source #

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

liftA2 :: (a -> b -> c) -> Opaque val a -> Opaque val b -> Opaque val c Source #

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

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

(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) => MonadIO (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

liftIO :: IO a -> Opaque val a Source #

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

empty :: Opaque val a Source #

(<|>) :: Opaque val a -> Opaque val a -> Opaque val a Source #

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

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

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

mzero :: Opaque val a Source #

mplus :: Opaque val a -> Opaque val a -> Opaque val a 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 #

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

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

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

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> 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 => 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 uni val => MakeKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Maybe cause -> SomeConstant uni rep -> MakeKnownM cause val 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

(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

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)

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.

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 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 RuntimeSchemes 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

Methods

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

knownMonoruntime :: RuntimeScheme (Length (arg ': args)) Source #

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

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

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

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

Convert a BuiltinMeaning to a BuiltinRuntime given an UnliftingMode and a cost model.

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.

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

(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

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 #

KnownTypeAst DefaultUni Int64 Source # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type ToHoles Int64 :: [Hole] Source #

type ToBinds Int64 :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy Int64 -> 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 #

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 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 #

Methods

toTypeAst :: proxy ByteString -> Type TyName DefaultUni () 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 #

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) 

throwKnownTypeErrorWithCause :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err, AsEvaluationFailure err) => ErrorWithCause KnownTypeError cause -> m void Source #

Throw a ErrorWithCause KnownTypeError cause.

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

type MakeKnownM cause = ExceptT (ErrorWithCause KnownTypeError cause) Emitter Source #

The monad that makeKnown runs in.

type ReadKnownM cause = Either (ErrorWithCause KnownTypeError cause) Source #

The monad that readKnown runs in.

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.

default makeKnown :: KnownBuiltinType val a => Maybe cause -> a -> MakeKnownM cause val Source #

Instances

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> Int -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> Int64 -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> Data -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> Bool -> MakeKnownM cause term Source #

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

Methods

makeKnown :: Maybe cause -> Text -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> ByteString -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Default.Universe

Methods

makeKnown :: Maybe cause -> Integer -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Examples.Builtins

Methods

makeKnown :: Maybe cause -> Void -> MakeKnownM cause term Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

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

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

Defined in PlutusCore.Builtin.KnownType

Methods

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

(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

Methods

makeKnown :: Maybe cause -> SomeConstant uni rep -> MakeKnownM cause val Source #

(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 #

type MakeKnown val = MakeKnownIn (UniOf val) val 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.

default readKnown :: KnownBuiltinType val a => Maybe cause -> val -> ReadKnownM cause a Source #

Instances

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Int Source #

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Int64 Source #

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Data Source #

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Bool Source #

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

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Text Source #

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause ByteString Source #

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

Defined in PlutusCore.Default.Universe

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Integer Source #

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

Defined in PlutusCore.Examples.Builtins

Methods

readKnown :: Maybe cause -> term -> ReadKnownM cause Void Source #

(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

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause (Emitter a) Source #

(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

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause (EvaluationResult a) Source #

(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 #

type ReadKnown val = ReadKnownIn (UniOf val) val Source #

makeKnownRun :: MakeKnownIn uni val a => Maybe cause -> a -> (ReadKnownM cause val, DList Text) 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.

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

Methods

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

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

HasConstant (CkValue uni fun) Source # 
Instance details

Defined in PlutusCore.Evaluation.Machine.Ck

Methods

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

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

HasConstant (CekValue uni fun) Source # 
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

Methods

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

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

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

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 #

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.