plutus-core-1.60.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore

Synopsis

parseTerm :: (Text -> m (Term TyName Name DefaultUni DefaultFun SrcSpan) #

Parse a PLC term. The resulting program will have fresh names. The underlying monad must be capable of handling any parse errors.

parseType :: (Text -> m (Type TyName DefaultUni SrcSpan) #

Parse a PLC type. The resulting program will have fresh names. The underlying monad must be capable of handling any parse errors.

data SourcePos #

The data type SourcePos represents source positions. It contains the name of the source file, a line number, and a column number. Source line and column positions change intensively during parsing, so we need to make them strict to avoid memory leaks.

Instances

Instances details
Text.Megaparsec.Pos

type Rep SourcePos = D1 ('MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-9.7.0-9IxnAL1Z5n8HX9bf04jh9I" 'False) (C1 ('MetaCons "SourcePos" 'PrefixI 'True) (S1 ('MetaSel ('Just "sourceName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath) :*: (S1 ('MetaSel ('Just "sourceLine") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Pos) :*: S1 ('MetaSel ('Just "sourceColumn") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Pos))))

data SrcSpan #

The span between two source locations.

This corresponds roughly to the SrcSpan used by GHC, but we define our own version so we don't have to depend on ghc to use it.

The line and column numbers are 1-based, and the unit is Unicode code point (or Char).

Constructors

SrcSpan 

Fields

Instances

Instances details
Generic SrcSpan # 
Instance details

Defined in PlutusCore.Annotation

Associated Types

type NumBits #

Pretty SrcSpans # 
Instance details

Defined in PlutusCore.Annotation

Methods

pretty :: SrcSpans -> Doc ann #

prettyList :: [SrcSpans] -> Doc ann #

type Element SrcSpans = SrcSpan

Builtins

data Some (tag :: k -> Type) where #

Existential. This is type is useful to hide GADTs' parameters.

>>> data Tag :: Type -> Type where TagInt :: Tag Int; TagBool :: Tag Bool
>>> instance GShow Tag where gshowsPrec _ TagInt = showString "TagInt"; gshowsPrec _ TagBool = showString "TagBool"
>>> classify s = case s of "TagInt" -> [mkGReadResult TagInt]; "TagBool" -> [mkGReadResult TagBool]; _ -> []
>>> instance GRead Tag where greadsPrec _ s = [ (r, rest) | (con, rest) <-  lex s, r <- classify con ]

You can either use PatternSynonyms (available with GHC >= 8.0)

>>> let x = Some TagInt
>>> x
Some TagInt
>>> case x of { Some TagInt -> "I"; Some TagBool -> "B" } :: String
"I"

or you can use functions

>>> let y = mkSome TagBool
>>> y
Some TagBool
>>> withSome y $ \y' -> case y' of { TagInt -> "I"; TagBool -> "B" } :: String
"B"

The implementation of mapSome is safe.

>>> let f :: Tag a -> Tag a; f TagInt = TagInt; f TagBool = TagBool
>>> mapSome f y
Some TagBool

but you can also use:

>>> withSome y (mkSome . f)
Some TagBool
>>> read "Some TagBool" :: Some Tag
Some TagBool
>>> read "mkSome TagInt" :: Some Tag
Some TagInt

Bundled Patterns

pattern Some :: forall {k} tag (a :: k). () => tag a -> Some tag 

Instances

Instances details
(Closed uni, Everywhere uni PrettyConst) => PrettyBy ConstConfig (Some (ValueOf uni)) # 
Instance details

Defined in PlutusCore.Pretty.PrettyConst

Methods

prettyBy :: ConstConfig -> Some (ValueOf uni) -> Doc ann #

prettyListBy :: ConstConfig -> [Some (ValueOf uni)] -> Doc ann #

NumBits #

(Closed uni, Everywhere uni PrettyConst) => Pretty (ValueOf uni a) # 
Instance details

Defined in PlutusCore.Pretty.PrettyConst

Methods

pretty :: ValueOf uni a -> Doc ann #

prettyList :: [ValueOf uni a] -> Doc ann #

(Closed uni, Everywhere uni PrettyConst) => Pretty (Some (ValueOf uni)) # 
Instance details

Defined in PlutusCore.Pretty.PrettyConst

Methods

pretty :: Some (ValueOf uni) -> Doc ann #

prettyList :: [Some (ValueOf uni)] -> Doc ann #

someValueOf :: forall a uni. uni (Esc a) -> a -> Some (ValueOf uni) #

Wrap a value into Some (ValueOf uni), given its explicit type tag.

someValue :: forall a uni. uni `Contains` a => a -> Some (ValueOf uni) #

Wrap a value into Some (ValueOf uni), provided its type is in the universe.

someValueType :: Some (ValueOf uni) -> SomeTypeIn uni #

data Esc a #

"Escapes" a type of an arbitrary kind to fit into Type.

class Contains uni a where #

A class for enumerating types and fully instantiated type formers that uni contains. For example, a particular ExampleUni may have monomorphic types in it:

instance ExampleUni Contains Integer where ... instance ExampleUni Contains Bool where ...

as well as polymorphic ones:

instance ExampleUni Contains [] where ... instance ExampleUni Contains (,) where ...

as well as their instantiations:

instance ExampleUni Contains a => ExampleUni Contains [a] where ... instance (ExampleUni Contains a, ExampleUni Contains b) => ExampleUni Contains (a, b) where ...

(a universe can have any subset of the mentioned sorts of types, for example it's fine to have instantiated polymorphic types and not have uninstantiated ones and vice versa)

Note that when used as a constraint of a function Contains does not allow you to directly express things like "uni has the Integer, Bool and [] types and type formers", because [] is not fully instantiated. So you can only say "uni has Integer, Bool, [Integer], [Bool], [[Integer]], [[Bool]] etc" and such manual enumeration is annoying, so we'd really like to be able to say that uni has lists of arbitrary built-in types (including lists of lists etc). Contains does not allow that, but Includes does. For example, in the body of the following definition:

foo :: (uni Includes Integer, uni Includes Bool, uni Includes []) => ... foo = ...

you can make use of the fact that uni has lists of arbitrary included types (integers, booleans and lists).

Hence most of the time opt for using the more flexible Includes.

Includes is defined in terms of Contains, so you only need to provide a Contains instance per type from the universe and you'll get Includes for free.

Methods

knownUni :: uni (Esc a) #

Instances

Instances details
Contains DefaultUni Text) #

Contains DefaultUni Vector) #

Contains DefaultUni List # 
Instance details

Defined in PlutusCore.Default.Universe

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) #

class Closed uni where #

A universe is Closed, if it's known how to constrain every type from the universe and every type can be encoded to / decoded from a sequence of integer tags. The universe doesn't have to be finite and providing support for infinite universes is the reason why we encode a type as a sequence of integer tags as opposed to a single integer tag. For example, given

  data U a where
      UList :: !(U a) -> U [a]
      UInt  :: U Int

UList (UList UInt) can be encoded to [0,0,1] where 0 and 1 are the integer tags of the UList and UInt constructors, respectively.

Associated Types

type Everywhere uni (constr :: Type -> Constraint) :: Constraint #

A constrant for "constr a holds for any a from uni".

Methods

encodeUni :: uni a -> [Int] #

Encode a type as a sequence of Int tags. The opposite of decodeUni.

withDecodedUni :: (forall k (a :: k). Typeable k => uni (Esc a) -> DecodeUniM r) -> DecodeUniM r #

Decode a type and feed it to the continuation.

bring :: uni `Everywhere` constr => proxy constr -> uni (Esc a) -> (constr a => r) -> r #

Bring a constr a instance in scope, provided a is a type from the universe and constr holds for any type from the universe.

Instances

Instances details
Closed DefaultUni # 
Instance details

Defined in PlutusCore.Default.Universe

Associated Types

type Everywhere DefaultUni constr #

Methods

encodeUni :: DefaultUni a -> [Int] #

withDecodedUni :: (forall k (a :: k). Typeable k => DefaultUni (Esc a) -> DecodeUniM r) -> DecodeUniM r #

bring :: Everywhere DefaultUni constr => proxy constr -> DefaultUni (Esc a) -> (constr a => r) -> r #

type family EverywhereAll uni constrs where ... #

Equations

EverywhereAll uni '[] = () 
EverywhereAll uni (constr ': constrs) = (uni `Everywhere` constr, uni `EverywhereAll` constrs) 

knownUniOf :: uni `Contains` a => proxy a -> uni (Esc a) #

Same as knownUni, but receives a proxy.

class GShow (t :: k -> Type) where #

Show-like class for 1-type-parameter GADTs. GShow t => ... is equivalent to something like (forall a. Show (t a)) => .... The easiest way to create instances would probably be to write (or derive) an instance Show (T a), and then simply say:

instance GShow t where gshowsPrec = defaultGshowsPrec

Methods

gshowsPrec :: forall (a :: k). GOrdering a a0 -> ShowS #

(GShow a, GShow b) => GShow (Product a b :: k -> Type)
>>> gshow (Pair Refl Refl :: Product ((:~:) Int) ((:~:) Int) Int)
"Pair Refl Refl"
Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec :: forall (a0 :: k0). Int -> Product a b a0 -> ShowS #

(GShow a, GShow b) => GShow (Sum a b :: k -> Type)
>>> gshow (InL Refl :: Sum ((:~:) Int) ((:~:) Bool) Int)
"InL Refl"
Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec :: forall (a0 :: k0). Int -> (a :~~: a0) -> ShowS #

(GShow a, GShow b) => GShow (a :*: b :: k -> Type)
>>> gshow (Pair Refl Refl :: Product ((:~:) Int) ((:~:) Int) Int)
"Refl :*: Refl"

Since: some-1.0.4

Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec :: forall (a0 :: k0). Int -> (a :*: b) a0 -> ShowS #

(GShow a, GShow b) => GShow (a :+: b :: k -> Type)
>>> gshow (L1 Refl :: ((:~:) Int :+: (:~:) Bool) Int)
"L1 Refl"

Since: some-1.0.4

Instance details

Defined in Data.GADT.Internal

Methods

gshowsPrec :: forall (a0 :: k0). Int -> (a :+: b) a0 -> ShowS #

show :: Show a => a -> String #

A specialised variant of showsPrec, using precedence context zero, and returning an ordinary String.

class GEq (f :: k -> Type) where #

A class for type-contexts which contain enough information to (at least in some cases) decide the equality of types occurring within them.

This class is sometimes confused with TestEquality from base. TestEquality only checks type equality.

Consider

>>> data Tag a where TagInt1 :: Tag Int; TagInt2 :: Tag Int

The correct TestEquality Tag instance is

>>> :{
instance TestEquality Tag where
    testEquality TagInt1 TagInt1 = Just Refl
    testEquality TagInt1 TagInt2 = Just Refl
    testEquality TagInt2 TagInt1 = Just Refl
    testEquality TagInt2 TagInt2 = Just Refl
:}

While we can define

instance GEq Tag where
   geq = testEquality

this will mean we probably want to have

instance Eq Tag where
   _ == _ = True

Note: In the future version of some package (to be released around GHC-9.6 / 9.8) the forall a. Eq (f a) constraint will be added as a constraint to GEq, with a law relating GEq and Eq:

geq x y = Just Refl   ⇒  x == y = True        ∀ (x :: f a) (y :: f b)
x == y                ≡  isJust (geq x y)     ∀ (x, y :: f a)

So, the more useful GEq Tag instance would differentiate between different constructors:

>>> :{
instance GEq Tag where
    geq TagInt1 TagInt1 = Just Refl
    geq TagInt1 TagInt2 = Nothing
    geq TagInt2 TagInt1 = Nothing
    geq TagInt2 TagInt2 = Just Refl
:}

which is consistent with a derived Eq instance for Tag

>>> deriving instance Eq (Tag a)

Note that even if a ~ b, the geq (x :: f a) (y :: f b) may be Nothing (when value terms are inequal).

The consistency of GEq and Eq is easy to check by exhaustion:

>>> let checkFwdGEq :: (forall a. Eq (f a), GEq f) => f a -> f b -> Bool; checkFwdGEq x y = case geq x y of Just Refl -> x == y; Nothing -> True
>>> (checkFwdGEq TagInt1 TagInt1, checkFwdGEq TagInt1 TagInt2, checkFwdGEq TagInt2 TagInt1, checkFwdGEq TagInt2 TagInt2)
(True,True,True,True)
>>> let checkBwdGEq :: (Eq (f a), GEq f) => f a -> f a -> Bool; checkBwdGEq x y = if x == y then isJust (geq x y) else isNothing (geq x y)
>>> (checkBwdGEq TagInt1 TagInt1, checkBwdGEq TagInt1 TagInt2, checkBwdGEq TagInt2 TagInt1, checkBwdGEq TagInt2 TagInt2)
(True,True,True,True)

Methods

geq :: forall (a :: k) (b :: k). f a -> f b -> Maybe (a :~: b) #

Produce a witness of type-equality, if one exists.

A handy idiom for using this would be to pattern-bind in the Maybe monad, eg.:

extract :: GEq tag => tag a -> DSum tag -> Maybe a
extract t1 (t2 :=> x) = do
    Refl <- geq t1 t2
    return x

Or in a list comprehension:

extractMany :: GEq tag => tag a -> [DSum tag] -> [a]
extractMany t1 things = [ x | (t2 :=> x) <- things, Refl <- maybeToList (geq t1 t2)]

(Making use of the DSum type from Data.Dependent.Sum in both examples)

Instances

Instances details
GEq Data.GADT.Internal

Methods

geq :: forall (a :: k0) (b :: k0). (f :+: g) a -> (f :+: g) b -> Maybe (a :~: b) #

class HasUniApply (uni :: Type -> Type) where #

A class for "uni has general type application".

Methods

uniApply :: forall k l (f :: k -> l) a. uni (Esc f) -> uni (Esc a) -> uni (Esc (f a)) #

Apply a type constructor to an argument.

matchUniApply #

Arguments

:: uni tb

The type.

-> r

What to return if the type is not an application.

-> (forall k l (f :: k -> l) a. tb ~ Esc (f a) => uni (Esc f) -> uni (Esc a) -> r)

The continuation taking a function and an argument.

-> r 

Deconstruct a type application into the function and the argument and feed them to the continuation. If the type is not an application, then return the default value.

Instances

Instances details
HasUniApply DefaultUni # 
Instance details

Defined in PlutusCore.Default.Universe

Methods

uniApply :: forall k l (f :: k -> l) (a :: k). DefaultUni (Esc f) -> DefaultUni (Esc a) -> DefaultUni (Esc (f a)) #

matchUniApply :: DefaultUni tb -> r -> (forall k l (f :: k -> l) (a :: k). tb ~ Esc (f a) => DefaultUni (Esc f) -> DefaultUni (Esc a) -> r) -> r #

checkStar :: forall uni a (x :: a). Typeable a => uni (Esc x) -> Maybe (a :~: Type) #

Check if the kind of the given type from the universe is Type.

withApplicable :: forall (a :: Type) (ab :: Type) f x uni m r. (Typeable ab, Typeable a, MonadPlus m) => uni (Esc (f :: ab)) -> uni (Esc (x :: a)) -> (forall (b :: Type). (Typeable b, ab ~ (a -> b)) => m r) -> m r #

Check if one type from the universe can be applied to another (i.e. check that the expected kind of the argument matches the actual one) and call the continuation in the refined context. Fail with mzero otherwise.

data (a :: k) :~: (b :: k) where infix 4 #

Propositional equality. If a :~: b is inhabited by some terminating value, then the type a is the same as the type b. To use this equality in practice, pattern-match on the a :~: b to get out the Refl constructor; in the body of the pattern-match, the compiler knows that a ~ b.

Since: base-4.7.0.0

Constructors

Refl :: forall {k} (a :: k). a :~: a 

Instances

Instances details
Text :: [RenderContext -> [SomeTypeIn DefaultUni] -> Doc ann #

Show (DefaultUni a) # 
Instance details

Defined in PlutusCore.Default.Universe

Pretty (DefaultUni a) #

This always pretty-prints parens around type applications (e.g. (list bool)) and doesn't pretty-print them otherwise (e.g. integer).

Instance details

Defined in PlutusCore.Default.Universe

Methods

pretty :: DefaultUni a -> Doc ann #

prettyList :: [DefaultUni a] -> Doc ann #

Pretty (SomeTypeIn DefaultUni) # 
Instance details

Defined in PlutusCore.Default.Universe

Contains DefaultUni Text)
type ToHoles DefaultUni hole Vector) => DefaultUni (Esc a1) -> DefaultUni a #

data DefaultFun #

Default built-in functions.

When updating these, make sure to add them to the protocol version listing! See Note [New builtins/language versions and protocol versions]

Constructors

AddInteger 
SubtractInteger 
MultiplyInteger 
DivideInteger 
QuotientInteger 
RemainderInteger 
ModInteger 
EqualsInteger 
LessThanInteger 
LessThanEqualsInteger 
AppendByteString 
ConsByteString 
SliceByteString 
LengthOfByteString 
IndexByteString 
EqualsByteString 
LessThanByteString 
LessThanEqualsByteString 
Sha2_256 
Sha3_256 
Blake2b_256 
VerifyEd25519Signature 
VerifyEcdsaSecp256k1Signature 
VerifySchnorrSecp256k1Signature 
AppendString 
EqualsString 
EncodeUtf8 
DecodeUtf8 
IfThenElse 
ChooseUnit 
Trace 
FstPair 
SndPair 
ChooseList 
MkCons 
HeadList 
TailList 
NullList 
ChooseData 
ConstrData 
MapData 
ListData 
IData 
BData 
UnConstrData 
UnMapData 
UnListData 
UnIData 
UnBData 
EqualsData 
SerialiseData 
MkPairData 
MkNilData 
MkNilPairData 
Bls12_381_G1_add 
Bls12_381_G1_neg 
Bls12_381_G1_scalarMul 
Bls12_381_G1_equal 
Bls12_381_G1_hashToGroup 
Bls12_381_G1_compress 
Bls12_381_G1_uncompress 
Bls12_381_G2_add 
Bls12_381_G2_neg 
Bls12_381_G2_scalarMul 
Bls12_381_G2_equal 
Bls12_381_G2_hashToGroup 
Bls12_381_G2_compress 
Bls12_381_G2_uncompress 
Bls12_381_millerLoop 
Bls12_381_mulMlResult 
Bls12_381_finalVerify 
Keccak_256 
Blake2b_224 
IntegerToByteString 
ByteStringToInteger 
AndByteString 
OrByteString 
XorByteString 
ComplementByteString 
ReadBit 
WriteBits 
ReplicateByte 
ShiftByteString 
RotateByteString 
CountSetBits 
FindFirstSetBit 
Ripemd_160 
ExpModInteger 
DropList 
LengthOfArray 
ListToArray 
IndexArray 
Bls12_381_G1_multiScalarMul 
Bls12_381_G2_multiScalarMul 
InsertCoin 
LookupCoin 
UnionValue 
ValueContains 
ValueData 
UnValueData 
ScaleValue 

Instances

Instances details
NumBits #

Pretty DefaultFun # 
Instance details

Defined in PlutusCore.Default.Builtins

Methods

pretty :: DefaultFun -> Doc ann #

prettyList :: [DefaultFun] -> Doc ann #

uni ThunkInfo) #

showTypeOf :: Proxy (BuiltinSemanticsVariant DefaultFun) -> String #

Pretty (BuiltinSemanticsVariant DefaultFun) # 
Instance details

Defined in PlutusCore.Default.Builtins

type Rep DefaultFun # 
Instance details

Defined in PlutusCore.Default.Builtins

type Rep DefaultFun = D1 ('MetaData "DefaultFun" "PlutusCore.Default.Builtins" "plutus-core-1.60.0.0-inplace" 'False) ((((((C1 ('MetaCons "AddInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SubtractInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MultiplyInteger" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "DivideInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "QuotientInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RemainderInteger" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "ModInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EqualsInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LessThanInteger" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "LessThanEqualsInteger" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AppendByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ConsByteString" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "SliceByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LengthOfByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IndexByteString" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "EqualsByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LessThanByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LessThanEqualsByteString" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Sha2_256" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Sha3_256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Blake2b_256" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "VerifyEd25519Signature" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "VerifyEcdsaSecp256k1Signature" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "VerifySchnorrSecp256k1Signature" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "AppendString" 'PrefixI 'False) (U1 :: Type -> Type)))))) :+: ((((C1 ('MetaCons "EqualsString" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "EncodeUtf8" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DecodeUtf8" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "IfThenElse" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ChooseUnit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Trace" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "FstPair" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "SndPair" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ChooseList" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "MkCons" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "HeadList" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TailList" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "NullList" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ChooseData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ConstrData" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "MapData" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ListData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "IData" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "BData" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "UnConstrData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UnMapData" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "UnListData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UnIData" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "UnBData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EqualsData" 'PrefixI 'False) (U1 :: Type -> Type))))))) :+: (((((C1 ('MetaCons "SerialiseData" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "MkPairData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MkNilData" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "MkNilPairData" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G1_add" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G1_neg" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Bls12_381_G1_scalarMul" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G1_equal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G1_hashToGroup" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Bls12_381_G1_compress" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G1_uncompress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G2_add" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "Bls12_381_G2_neg" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G2_scalarMul" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G2_equal" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Bls12_381_G2_hashToGroup" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G2_compress" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G2_uncompress" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "Bls12_381_millerLoop" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_mulMlResult" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_finalVerify" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "Keccak_256" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Blake2b_224" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "IntegerToByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ByteStringToInteger" 'PrefixI 'False) (U1 :: Type -> Type)))))) :+: ((((C1 ('MetaCons "AndByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OrByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "XorByteString" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "ComplementByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ReadBit" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WriteBits" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "ReplicateByte" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "ShiftByteString" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RotateByteString" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "CountSetBits" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FindFirstSetBit" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Ripemd_160" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExpModInteger" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "DropList" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LengthOfArray" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ListToArray" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "IndexArray" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Bls12_381_G1_multiScalarMul" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Bls12_381_G2_multiScalarMul" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "InsertCoin" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LookupCoin" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "UnionValue" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ValueContains" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ValueData" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "UnValueData" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ScaleValue" 'PrefixI 'False) (U1 :: Type -> Type))))))))
data BuiltinSemanticsVariant DefaultFun # 
Instance details

Defined in PlutusCore.Default.Builtins

type CostingPart uni DefaultFun # 
Instance details

Defined in PlutusCore.Default.Builtins

type Rep (BuiltinSemanticsVariant DefaultFun) # 
Instance details

Defined in PlutusCore.Default.Builtins

type Rep (BuiltinSemanticsVariant DefaultFun) = D1 ('MetaData "BuiltinSemanticsVariant" "PlutusCore.Default.Builtins" "plutus-core-1.60.0.0-inplace" 'False) ((C1 ('MetaCons "DefaultFunSemanticsVariantA" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DefaultFunSemanticsVariantB" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "DefaultFunSemanticsVariantC" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DefaultFunSemanticsVariantD" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DefaultFunSemanticsVariantE" 'PrefixI 'False) (U1 :: Type -> Type))))

AST

data Term tyname name uni fun ann #

Constructors

Var ann name

a named variable

LamAbs ann name (Type tyname uni ann) (Term tyname name uni fun ann)

lambda abstraction

Apply ann (Term tyname name uni fun ann) (Term tyname name uni fun ann)

application

TyAbs ann tyname (Kind ann) (Term tyname name uni fun ann)

type abstraction

TyInst ann (Term tyname name uni fun ann) (Type tyname uni ann)

instantiation

IWrap ann (Type tyname uni ann) (Type tyname uni ann) (Term tyname name uni fun ann)

wrapping

Unwrap ann (Term tyname name uni fun ann)

unwrapping See Note [Constr tag type]

Constr ann (Type tyname uni ann) Word64 [Term tyname name uni fun ann]

constructor

Case ann (Type tyname uni ann) (Term tyname name uni fun ann) [Term tyname name uni fun ann]

case

Constant ann (Some (ValueOf uni))

constants

Builtin ann fun

builtin functions

Error ann (Type tyname uni ann)

fail with error

Instances

Instances details
name NumBits #

Pretty ann => Pretty (Kind ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Pretty.Default

Methods

pretty :: Kind ann -> Doc ann0 #

prettyList :: [Kind ann] -> Doc ann0 #

Pretty ann => PrettyBy (PrettyConfigClassic configName) (Kind ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Pretty.Classic

Methods

prettyBy :: PrettyConfigClassic configName -> Kind ann -> Doc ann0 #

prettyListBy :: PrettyConfigClassic configName -> [Kind ann] -> Doc ann0 #

PrettyBy (PrettyConfigReadable configName) (Kind a) # 
Instance details

Defined in PlutusCore.Core.Instance.Pretty.Readable

Methods

prettyBy :: PrettyConfigReadable configName -> Kind a -> Doc ann #

prettyListBy :: PrettyConfigReadable configName -> [Kind a] -> Doc ann #

type Rep (Kind ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Kind ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Kind ann) = ()

toPatFuncKind :: Kind () -> Kind () #

The kind of a pattern functor (the first Kind argument of TyIFix) at a given kind (of the second Kind argument of TyIFix):

toPatFuncKind k = (k -> *) -> k -> * 

data Version #

The version of Plutus Core used by this program.

The intention is to convey different levels of backwards compatibility for existing scripts: - Major version changes are backwards-incompatible - Minor version changes are backwards-compatible - Patch version changes should be entirely invisible (and we will likely not use this level)

The version used should be changed only when the language itself changes. For example, adding a new kind of term to the language would require a minor version bump; removing a kind of term would require a major version bump.

Similarly, changing the semantics of the language will require a version bump, typically a major one. This is the main reason why the version is actually tracked in the AST: we can have two language versions with identical ASTs but different semantics, so we need to track the version explicitly.

Compatibility is about compatibility for specific scripts, not about e.g. tools which consume scripts. Adding a new kind of term does not change how existing scripts behave, but does change what tools would need to do to process scripts.

Constructors

Version 

Instances

Instances details
Generic Version # 
Instance details

Defined in PlutusCore.Version

Associated Types

type Text) :*: S1 ('MetaSel ('Just "_nameUnique") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Unique)))

newtype TyName #

We use a newtype to enforce separation between names used for types and those used for terms.

Constructors

TyName 

Fields

Instances

Instances details
Generic TyName # 
Instance details

Defined in PlutusCore.Name.Unique

Associated Types

type NumBits #

(GEq uni, Eq ann) => Eq (Type TyName uni ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==) :: Type TyName uni ann -> Type TyName uni ann -> Bool #

(/=) :: Type TyName uni ann -> Type TyName uni ann -> Bool #

TermLike (Term name uni fun) TyName name uni fun # 
Instance details

Defined in UntypedPlutusCore.Core.Type

Methods

var :: ann -> name -> Term name uni fun ann #

tyAbs :: ann -> TyName -> Kind ann -> Term name uni fun ann -> Term name uni fun ann #

lamAbs :: ann -> name -> Type TyName uni ann -> Term name uni fun ann -> Term name uni fun ann #

apply :: ann -> Term name uni fun ann -> Term name uni fun ann -> Term name uni fun ann #

constant :: ann -> Some (ValueOf uni) -> Term name uni fun ann #

builtin :: ann -> fun -> Term name uni fun ann #

tyInst :: ann -> Term name uni fun ann -> Type TyName uni ann -> Term name uni fun ann #

unwrap :: ann -> Term name uni fun ann -> Term name uni fun ann #

iWrap :: ann -> Type TyName uni ann -> Type TyName uni ann -> Term name uni fun ann -> Term name uni fun ann #

error :: ann -> Type TyName uni ann -> Term name uni fun ann #

constr :: ann -> Type TyName uni ann -> Word64 -> [Term name uni fun ann] -> Term name uni fun ann #

kase :: ann -> Type TyName uni ann -> Term name uni fun ann -> [Term name uni fun ann] -> Term name uni fun ann #

termLet :: ann -> TermDef (Term name uni fun) TyName name uni ann -> Term name uni fun ann -> Term name uni fun ann #

typeLet :: ann -> TypeDef TyName uni ann -> Term name uni fun ann -> Term name uni fun ann #

(GEq uni, Closed uni, Everywhere uni Eq, Eq fun, Eq ann) => Eq (Term TyName Name uni fun ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==) :: Term TyName Name uni fun ann -> Term TyName Name uni fun ann -> Bool #

(/=) :: Term TyName Name uni fun ann -> Term TyName Name uni fun ann -> Bool #

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

Defined in PlutusCore.Builtin.HasConstant

Methods

asConstant :: Term TyName Name uni fun () -> Either BuiltinError (Some (ValueOf (UniOf (Term TyName Name uni fun ())))) #

fromConstant :: Some (ValueOf (UniOf (Term TyName Name uni fun ()))) -> Term TyName Name uni fun () #

type Rep TyName # 
Instance details

Defined in PlutusCore.Name.Unique

type Rep TyName = D1 ('MetaData "TyName" "PlutusCore.Name.Unique" "plutus-core-1.60.0.0-inplace" 'True) (C1 ('MetaCons "TyName" 'PrefixI 'True) (S1 ('MetaSel ('Just "unTyName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name)))
type Unwrapped TyName # 
Instance details

Defined in PlutusCore.Name.Unique

type Unwrapped TyName = GUnwrapped (Rep TyName)

newtype Unique #

A unique identifier This is normally a positive integral number, except in topUnique where we make use of a negative unique to signify top-level.

Constructors

Unique 

Fields

Pretty Unique # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

pretty :: Unique -> Doc ann #

prettyList :: [Unique] -> Doc ann #

HasUnique Unique Unique # 
Instance details

Defined in PlutusCore.Name.Unique

Lift Unique # 
Instance details

Defined in PlutusCore.Name.Unique

Methods

lift :: Quote m => Unique -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Unique -> Code m Unique #

newtype UniqueMap unique a #

A mapping from Uniques to arbitrary values of type a. Since Unique is equivalent to Int (see PlutusCore.Name.Unique), we can use an IntMap representation for this type.

Constructors

UniqueMap 

Fields

Instances

Instances details
Foldable (UniqueMap unique) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

fold :: Monoid m => UniqueMap unique m -> m #

foldMap :: Monoid m => (a -> m) -> UniqueMap unique a -> m #

foldMap' :: Monoid m => (a -> m) -> UniqueMap unique a -> m #

foldr :: (a -> b -> b) -> b -> UniqueMap unique a -> b #

foldr' :: (a -> b -> b) -> b -> UniqueMap unique a -> b #

foldl :: (b -> a -> b) -> b -> UniqueMap unique a -> b #

foldl' :: (b -> a -> b) -> b -> UniqueMap unique a -> b #

foldr1 :: (a -> a -> a) -> UniqueMap unique a -> a #

foldl1 :: (a -> a -> a) -> UniqueMap unique a -> a #

toList :: UniqueMap unique a -> [a] #

null :: UniqueMap unique a -> Bool #

length :: UniqueMap unique a -> Int #

elem :: Eq a => a -> UniqueMap unique a -> Bool #

maximum :: Ord a => UniqueMap unique a -> a #

minimum :: Ord a => UniqueMap unique a -> a #

sum :: Num a => UniqueMap unique a -> a #

product :: Num a => UniqueMap unique a -> a #

Functor (UniqueMap unique) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

fmap :: (a -> b) -> UniqueMap unique a -> UniqueMap unique b #

(<$) :: a -> UniqueMap unique b -> UniqueMap unique a #

Monoid (UniqueMap unique a) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

mempty :: UniqueMap unique a #

mappend :: UniqueMap unique a -> UniqueMap unique a -> UniqueMap unique a #

mconcat :: [UniqueMap unique a] -> UniqueMap unique a #

Semigroup (UniqueMap unique a) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

(<>) :: UniqueMap unique a -> UniqueMap unique a -> UniqueMap unique a #

sconcat :: NonEmpty (UniqueMap unique a) -> UniqueMap unique a #

stimes :: Integral b => b -> UniqueMap unique a -> UniqueMap unique a #

Show a => Show (UniqueMap unique a) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

showsPrec :: Int -> UniqueMap unique a -> ShowS #

show :: UniqueMap unique a -> String #

showList :: [UniqueMap unique a] -> ShowS #

Eq a => Eq (UniqueMap unique a) # 
Instance details

Defined in PlutusCore.Name.UniqueMap

Methods

(==) :: UniqueMap unique a -> UniqueMap unique a -> Bool #

(/=) :: UniqueMap unique a -> UniqueMap unique a -> Bool #

newtype UniqueSet unique #

A set containing Uniques. Since Unique is equivalent to Int (see PlutusCore.Name.Unique), we can use an IntSet representation for this type.

Constructors

UniqueSet 
(GEq uni, Closed uni, Everywhere uni Eq, Eq ann) => Eq (Type NamedTyDeBruijn uni ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

Methods

(==) :: Type NamedTyDeBruijn uni ann -> Type NamedTyDeBruijn uni ann -> Bool #

(/=) :: Type NamedTyDeBruijn uni ann -> Type NamedTyDeBruijn uni ann -> Bool #

(GEq uni, Closed uni, Everywhere uni Eq, Eq fun, Eq ann) => Eq (Term NamedTyDeBruijn NamedDeBruijn uni fun ann) # 
Instance details

Defined in PlutusCore.Core.Instance.Eq

type Rep NamedTyDeBruijn # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep NamedTyDeBruijn = D1 ('MetaData "NamedTyDeBruijn" "PlutusCore.DeBruijn.Internal" "plutus-core-1.60.0.0-inplace" 'True) (C1 ('MetaCons "NamedTyDeBruijn" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NamedDeBruijn)))
type Unwrapped NamedTyDeBruijn # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Unwrapped NamedTyDeBruijn = GUnwrapped (Rep NamedTyDeBruijn)

deBruijnTerm :: MonadError FreeVariableError m => Term TyName Name uni fun ann -> m (Term NamedTyDeBruijn NamedDeBruijn uni fun ann) #

Convert a Term with TyNames and Names into a Term with NamedTyDeBruijns and NamedDeBruijns. Will throw an error if a free variable is encountered.

unDeBruijnTerm :: (MonadQuote m, MonadError FreeVariableError m) => Term NamedTyDeBruijn NamedDeBruijn uni fun ann -> m (Term TyName Name uni fun ann) #

Convert a Term with NamedTyDeBruijns and NamedDeBruijns into a Term with TyNames and Names. Will throw an error if a free variable is encountered.

Processing

type family HasUniques a :: Constraint #

All kinds of uniques an entity contains.

Instances

Instances details
type HasUniques (Kind ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Kind ann) = ()
type HasUniques (Type tyname uni ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Type tyname uni ann) = HasUnique tyname TypeUnique
type HasUniques (Program name uni fun ann) # 
Instance details

Defined in UntypedPlutusCore.Core.Type

type HasUniques (Program name uni fun ann) = HasUniques (Term name uni fun ann)
type HasUniques (Term name uni fun ann) # 
Instance details

Defined in UntypedPlutusCore.Core.Type

type HasUniques (Term name uni fun ann) = HasUnique name TermUnique
type HasUniques (Program tyname name uni fun ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Program tyname name uni fun ann) = HasUniques (Term tyname name uni fun ann)
type HasUniques (Term tyname name uni fun ann) # 
Instance details

Defined in PlutusCore.Core.Type

type HasUniques (Term tyname name uni fun ann) = (HasUnique tyname TypeUnique, HasUnique name TermUnique)

class Rename a where #

The class of things that can be renamed. I.e. things that are capable of satisfying the global uniqueness condition.

Methods

rename :: MonadQuote m => a -> m a #

Rename Uniques so that they're globally unique. In case there are any free variables, they must be left untouched and bound variables must not get renamed to free ones. Must always assign new names to bound variables, so that rename can be used for alpha-renaming as well.

Instances

Instances details
Rename a => Rename (Normalized a) # 
Instance details

Defined in PlutusCore.Rename

Methods

rename :: MonadQuote m => Normalized a -> m (Normalized a) #

HasUniques (Type tyname uni ann) => Rename (Type tyname uni ann) # 
Instance details

Defined in PlutusCore.Rename

Methods

rename :: MonadQuote m => Type tyname uni ann -> m (Type tyname uni ann) #

HasUniques (Program name uni fun ann) => Rename (Program name uni fun ann) # 
Instance details

Defined in UntypedPlutusCore.Rename

Methods

rename :: MonadQuote m => Program name uni fun ann -> m (Program name uni fun ann) #

HasUniques (Term name uni fun ann) => Rename (Term name uni fun ann) # 
Instance details

Defined in UntypedPlutusCore.Rename

Methods

rename :: MonadQuote m => Term name uni fun ann -> m (Term name uni fun ann) #

HasUniques (Program tyname name uni fun ann) => Rename (Program tyname name uni fun ann) # 
Instance details

Defined in PlutusCore.Rename

Methods

rename :: MonadQuote m => Program tyname name uni fun ann -> m (Program tyname name uni fun ann) #

HasUniques (Term tyname name uni fun ann) => Rename (Term tyname name uni fun ann) # 
Instance details

Defined in PlutusCore.Rename

Methods

rename :: MonadQuote m => Term tyname name uni fun ann -> m (Term tyname name uni fun ann) #

Type checking

module PlutusCore.TypeCheck

normalizeTypesIn :: (HasUnique tyname TypeUnique, HasUnique name TermUnique, MonadNormalizeType uni m) => Term tyname name uni fun ann -> m (Term tyname name uni fun ann) #

Normalize every Kind in a Term.

normalizeTypesInProgram :: (HasUnique tyname TypeUnique, HasUnique name TermUnique, MonadNormalizeType uni m) => Program tyname name uni fun ann -> m (Program tyname name uni fun ann) #

Normalize every Kind in a Program.

data TypeError term uni fun ann #

Instances

Instances details
(Pretty term, PrettyUni uni, Pretty fun, Pretty ann) => PrettyBy PrettyConfigPlc (TypeError term uni fun ann) # 
Instance details

Defined in PlutusCore.Error

Methods

prettyBy :: PrettyConfigPlc -> TypeError term uni fun ann -> Doc ann0 #

prettyListBy :: PrettyConfigPlc -> [TypeError term uni fun ann] -> Doc ann0 #

Text))))

data UniqueError ann #

Constructors

MultiplyDefined !Unique !ann !ann 
IncoherentUsage !Unique !ann !ann 
FreeVariable !Unique !ann 

Instances

Instances details
Functor UniqueError # 
Instance details

Defined in PlutusCore.Error

Methods

fmap :: (a -> b) -> UniqueError a -> UniqueError b #

(<$) :: a -> UniqueError b -> UniqueError a #

Exception (UniqueError SrcSpan) # 
Instance details

Defined in PlutusCore.Error

Generic (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

Associated Types

type Rep (UniqueError ann) :: Type -> Type #

Methods

from :: UniqueError ann -> Rep (UniqueError ann) x #

to :: Rep (UniqueError ann) x -> UniqueError ann #

Show ann => Show (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

Methods

showsPrec :: Int -> UniqueError ann -> ShowS #

show :: UniqueError ann -> String #

showList :: [UniqueError ann] -> ShowS #

NFData ann => NFData (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

Methods

rnf :: UniqueError ann -> () #

Eq ann => Eq (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

Methods

(==) :: UniqueError ann -> UniqueError ann -> Bool #

(/=) :: UniqueError ann -> UniqueError ann -> Bool #

Pretty ann => Pretty (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

Methods

pretty :: UniqueError ann -> Doc ann0 #

prettyList :: [UniqueError ann] -> Doc ann0 #

type Rep (UniqueError ann) # 
Instance details

Defined in PlutusCore.Error

data FreeVariableError #

We cannot do a correct translation to or from de Bruijn indices if the program is not well-scoped. So we throw an error in such a case.

Constructors

FreeUnique !Unique 
FreeIndex !Index 

Instances

Instances details
Exception FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

Generic FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

Associated Types

type Rep FreeVariableError :: Type -> Type #

Show FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

Methods

rnf :: FreeVariableError -> () #

Eq FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

Ord FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

Pretty FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep FreeVariableError # 
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep FreeVariableError = D1 ('MetaData "FreeVariableError" "PlutusCore.DeBruijn.Internal" "plutus-core-1.60.0.0-inplace" 'False) (C1 ('MetaCons "FreeUnique" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Unique)) :+: C1 ('MetaCons "FreeIndex" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Index)))

Quotation and term construction

type Quote = QuoteT Identity #

A non-transformer version of QuoteT.

runQuote :: Quote a -> a #

See runQuoteT.

data QuoteT m a #

The "quotation" monad transformer. Within this monad you can do safe construction of PLC terms using quasiquotation, fresh-name generation, and parsing.

Instances

Instances details
MFunctor QuoteT # 
Instance details

Defined in PlutusCore.Quote

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> QuoteT m b -> QuoteT n b #

MonadError e m => MonadError e (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

throwError :: e -> QuoteT m a #

catchError :: QuoteT m a -> (e -> QuoteT m a) -> QuoteT m a #

MonadReader r m => MonadReader r (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

ask :: QuoteT m r #

local :: (r -> r) -> QuoteT m a -> QuoteT m a #

reader :: (r -> a) -> QuoteT m a #

MonadState s m => MonadState s (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

get :: QuoteT m s #

put :: s -> QuoteT m () #

state :: (s -> (a, s)) -> QuoteT m a #

MonadWriter w m => MonadWriter w (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

writer :: (a, w) -> QuoteT m a #

tell :: w -> QuoteT m () #

listen :: QuoteT m a -> QuoteT m (a, w) #

pass :: QuoteT m (a, w -> w) -> QuoteT m a #

MonadFix m => MonadFix (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

mfix :: (a -> QuoteT m a) -> QuoteT m a #

MonadIO m => MonadIO (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

liftIO :: IO a -> QuoteT m a #

Monad m => Applicative (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

pure :: a -> QuoteT m a #

(<*>) :: QuoteT m (a -> b) -> QuoteT m a -> QuoteT m b #

liftA2 :: (a -> b -> c) -> QuoteT m a -> QuoteT m b -> QuoteT m c #

(*>) :: QuoteT m a -> QuoteT m b -> QuoteT m b #

(<*) :: QuoteT m a -> QuoteT m b -> QuoteT m a #

Functor m => Functor (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

fmap :: (a -> b) -> QuoteT m a -> QuoteT m b #

(<$) :: a -> QuoteT m b -> QuoteT m a #

Monad m => Monad (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

(>>=) :: QuoteT m a -> (a -> QuoteT m b) -> QuoteT m b #

(>>) :: QuoteT m a -> QuoteT m b -> QuoteT m b #

return :: a -> QuoteT m a #

Monad m => MonadQuote (QuoteT m) # 
Instance details

Defined in PlutusCore.Quote

Methods

liftQuote :: Quote a -> QuoteT m a #

runQuoteT :: Monad m => QuoteT m a -> m a #

Run a quote from an empty identifier state. Note that the resulting term cannot necessarily be safely combined with other terms - that should happen inside QuoteT.

class Text name.

Evaluation

data EvaluationResult a #

The parameterized type of results various evaluation engines return.

Constructors

EvaluationSuccess !a 
EvaluationFailure 

Instances

Instances details
Some TyNameRep] #

Methods

typeAst :: Type0 tyname uni () #

(TypeError ('Text "Use \8216BuiltinResult\8217 instead of \8216EvaluationResult\8217") :: Constraint, uni ~ UniOf val) => MakeKnownIn uni val (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Builtin.KnownType

(TypeError ('Text "Use \8216BuiltinResult\8217 instead of \8216EvaluationResult\8217") :: Constraint, uni ~ UniOf val) => ReadKnownIn uni val (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: val -> ReadKnownM (EvaluationResult a) #

PrettyBy config a => PrettyBy config (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

prettyBy :: config -> EvaluationResult a -> Doc ann #

prettyListBy :: config -> [EvaluationResult a] -> Doc ann #

Generic (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

Associated Types

type Rep (EvaluationResult a) :: Type -> Type #

Show a => Show (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

NFData a => NFData (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

rnf :: EvaluationResult a -> () #

Eq a => Eq (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

PrettyClassic a => Pretty (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

Methods

pretty :: EvaluationResult a -> Doc ann #

prettyList :: [EvaluationResult a] -> Doc ann #

type ToBinds uni acc (EvaluationResult a :: Type) # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds uni acc (EvaluationResult a :: Type) = ToBinds uni acc a
type ToHoles uni _1 (EvaluationResult a :: Type) # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles uni _1 (EvaluationResult a :: Type) = '[TypeHole a :: Hole]
type IsBuiltin uni (EvaluationResult a :: Type) # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type Rep (EvaluationResult a) # 
Instance details

Defined in PlutusCore.Evaluation.Result

type Rep (EvaluationResult a) = D1 ('MetaData "EvaluationResult" "PlutusCore.Evaluation.Result" "plutus-core-1.60.0.0-inplace" 'False) (C1 ('MetaCons "EvaluationSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a)) :+: C1 ('MetaCons "EvaluationFailure" 'PrefixI 'False) (U1 :: Type -> Type))

Combining programs

applyProgram :: (MonadError ApplyProgramError m, Semigroup a) => Program tyname name uni fun a -> Program tyname name uni fun a -> m (Program tyname name uni fun a) #

Applies one program to another. Fails if the versions do not match and tries to merge annotations.

Benchmarking

termAstSize :: Term tyname name uni fun ann -> AstSize #

Count the number of AST nodes in a term.

typeAstSize :: Type tyname uni ann -> AstSize #

Count the number of AST nodes in a type.

kindAstSize :: Kind a -> AstSize #

Count the number of AST nodes in a kind.

>>> kindAstSize $ Type ()
AstSize {unAstSize = 1}
>>> kindAstSize $ KindArrow () (KindArrow () (Type ()) (Type ())) (Type ())
AstSize {unAstSize = 5} 

programAstSize :: Program tyname name uni fun ann -> AstSize #

Count the number of AST nodes in a program.