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

PlutusIR.Compiler

Synopsis

Documentation

compileProgramCompiling m uni fun a ⇒ Program TyName Name uni fun a → m (PLCProgram uni fun a) Source #

compileToReadable ∷ ∀ m uni fun a b. (Compiling m uni fun a, b ~ Provenance a) ⇒ Program TyName Name uni fun b → m (Program TyName Name uni fun b) Source #

The 1st half of the PIR compiler pipeline up to floating/merging the lets. We stop momentarily here to give a chance to the tx-plugin to dump a "readable" version of pir (i.e. floated).

compileReadableToPlc ∷ ∀ m uni fun a b. (Compiling m uni fun a, b ~ Provenance a) ⇒ Program TyName Name uni fun b → m (PLCProgram uni fun a) Source #

The 2nd half of the PIR compiler pipeline. Compiles a Term into a PLC Term, by removing/translating step-by-step the PIR's language constructs to PLC. Note: the result *does* have globally unique names.

type Compiling m uni fun a = (Monad m, MonadReader (CompilationCtx uni fun a) m, MonadError (Error uni fun (Provenance a)) m, MonadQuote m, Ord a, AnnInline a, Typecheckable uni fun, GEq uni, PrettyUni uni, Pretty fun, Pretty a) Source #

data Error uni fun a Source #

Constructors

CompilationError !a !Text

A generic compilation error.

UnsupportedError !a !Text

An error relating specifically to an unsupported feature.

OptionsError !Text

An error relating to compilation options.

PLCError !(Error uni fun a)

An error from running some PLC function, lifted into this error type for convenience.

PLCTypeError !(TypeError (Term TyName Name uni fun ()) uni fun a) 
PIRTypeError !(TypeErrorExt uni a) 

Instances

Instances details
(PrettyUni uni, Pretty fun, Pretty ann) ⇒ PrettyBy PrettyConfigPlc (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

prettyByPrettyConfigPlcError uni fun ann → Doc ann0 Source #

prettyListByPrettyConfigPlc → [Error uni fun ann] → Doc ann0 Source #

Functor (Error uni fun) Source # 
Instance details

Defined in PlutusIR.Error

Methods

fmap ∷ (a → b) → Error uni fun a → Error uni fun b Source #

(<$) ∷ a → Error uni fun b → Error uni fun a Source #

(ThrowableBuiltins uni fun, Pretty ann, Typeable ann) ⇒ Exception (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

toExceptionError uni fun ann → SomeException Source #

fromExceptionSomeExceptionMaybe (Error uni fun ann) Source #

displayExceptionError uni fun ann → String Source #

(PrettyUni uni, Pretty fun, Pretty ann) ⇒ Show (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

showsPrecIntError uni fun ann → ShowS Source #

showError uni fun ann → String Source #

showList ∷ [Error uni fun ann] → ShowS Source #

(PrettyUni uni, Pretty fun, Pretty ann) ⇒ Pretty (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

prettyError uni fun ann → Doc ann0 Source #

prettyList ∷ [Error uni fun ann] → Doc ann0 Source #

data Provenance a Source #

Indicates where a value comes from.

This is either an original annotation or a pieces of context explaining how the term relates to a previous Provenance. We also provide noProvenance for convenience.

The provenance should always be just the original annotation, if we have one. It should only be another kind of provenance if we're in the process of generating some term that doesn't correspond directly to a term in the original AST.

Constructors

Original a 
LetBinding Recursivity (Provenance a) 
TermBinding String (Provenance a) 
TypeBinding String (Provenance a) 
DatatypeComponent DatatypeComponent (Provenance a) 
MultipleSources (Set (Provenance a))

Added for accumulating difference provenances when floating lets

Instances

Instances details
Foldable Provenance Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Methods

foldMonoid m ⇒ Provenance m → m Source #

foldMapMonoid m ⇒ (a → m) → Provenance a → m Source #

foldMap'Monoid m ⇒ (a → m) → Provenance a → m Source #

foldr ∷ (a → b → b) → b → Provenance a → b Source #

foldr' ∷ (a → b → b) → b → Provenance a → b Source #

foldl ∷ (b → a → b) → b → Provenance a → b Source #

foldl' ∷ (b → a → b) → b → Provenance a → b Source #

foldr1 ∷ (a → a → a) → Provenance a → a Source #

foldl1 ∷ (a → a → a) → Provenance a → a Source #

toListProvenance a → [a] Source #

nullProvenance a → Bool Source #

lengthProvenance a → Int Source #

elemEq a ⇒ a → Provenance a → Bool Source #

maximumOrd a ⇒ Provenance a → a Source #

minimumOrd a ⇒ Provenance a → a Source #

sumNum a ⇒ Provenance a → a Source #

productNum a ⇒ Provenance a → a Source #

Ord a ⇒ Monoid (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Ord a ⇒ Semigroup (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Generic (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Associated Types

type Rep (Provenance a) ∷ TypeType Source #

Methods

fromProvenance a → Rep (Provenance a) x Source #

toRep (Provenance a) x → Provenance a Source #

Show a ⇒ Show (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Eq a ⇒ Eq (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Methods

(==)Provenance a → Provenance a → Bool Source #

(/=)Provenance a → Provenance a → Bool Source #

Ord a ⇒ Ord (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Hashable a ⇒ Hashable (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Methods

hashWithSaltIntProvenance a → Int Source #

hashProvenance a → Int Source #

AnnInline a ⇒ AnnInline (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Pretty a ⇒ Pretty (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Methods

prettyProvenance a → Doc ann Source #

prettyList ∷ [Provenance a] → Doc ann Source #

type Rep (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

type Rep (Provenance a) = D1 ('MetaData "Provenance" "PlutusIR.Compiler.Provenance" "plutus-core-1.46.0.0-inplace-plutus-ir" 'False) ((C1 ('MetaCons "Original" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "LetBinding" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Recursivity) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Provenance a))) :+: C1 ('MetaCons "TermBinding" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Provenance a))))) :+: (C1 ('MetaCons "TypeBinding" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Provenance a))) :+: (C1 ('MetaCons "DatatypeComponent" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatatypeComponent) :*: S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Provenance a))) :+: C1 ('MetaCons "MultipleSources" 'PrefixI 'False) (S1 ('MetaSel ('NothingMaybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set (Provenance a)))))))

data DatatypeComponent Source #

Instances

Instances details
Generic DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Associated Types

type Rep DatatypeComponentTypeType Source #

Show DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Eq DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Ord DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Hashable DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Pretty DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

type Rep DatatypeComponent Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

type Rep DatatypeComponent = D1 ('MetaData "DatatypeComponent" "PlutusIR.Compiler.Provenance" "plutus-core-1.46.0.0-inplace-plutus-ir" 'False) ((C1 ('MetaCons "Constructor" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "ConstructorType" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "Destructor" 'PrefixI 'False) (U1TypeType))) :+: (C1 ('MetaCons "DestructorType" 'PrefixI 'False) (U1TypeType) :+: (C1 ('MetaCons "DatatypeType" 'PrefixI 'False) (U1TypeType) :+: C1 ('MetaCons "PatternFunctor" 'PrefixI 'False) (U1TypeType))))

data DatatypeStyle Source #

What style to use when encoding datatypes. Generally, SumsOfProducts is superior, unless you are targeting an old Plutus Core language version.

See Note [Encoding of datatypes]

data CompilationCtx uni fun a Source #

ccOpts ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (CompilationOpts a) Source #

ccEnclosing ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (Provenance a) Source #

ccTypeCheckConfig ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (PirTCConfig uni fun) Source #

ccBuiltinsInfo ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (BuiltinsInfo uni fun) Source #

ccBuiltinCostModel ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (CostingPart uni fun) Source #

data PirTCConfig uni fun Source #

extending the plc typecheck config with AllowEscape

data AllowEscape Source #

Extra flag to be passed in the TypeCheckM Reader context, to signal if the PIR expression currently being typechecked is at the top-level and thus its type can escape, or nested and thus not allowed to escape.

Constructors

YesEscape 
NoEscape 

runCompilerPass ∷ (Compiling m uni fun a, b ~ Provenance a) ⇒ m (Pass m tyname name uni fun b) → Term tyname name uni fun b → m (Term tyname name uni fun b) Source #

simplifierCompiling m uni fun a ⇒ m (Pass m TyName Name uni fun (Provenance a)) Source #