Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- compileProgram ∷ Compiling m e uni fun a ⇒ Program TyName Name uni fun a → m (PLCProgram uni fun a)
- compileToReadable ∷ ∀ m e uni fun a b. (Compiling m e uni fun a, b ~ Provenance a) ⇒ Program TyName Name uni fun b → m (Program TyName Name uni fun b)
- compileReadableToPlc ∷ ∀ m e uni fun a b. (Compiling m e uni fun a, b ~ Provenance a) ⇒ Program TyName Name uni fun b → m (PLCProgram uni fun a)
- type Compiling m e uni fun a = (Monad m, MonadReader (CompilationCtx uni fun a) m, AsTypeError e (Term TyName Name uni fun ()) uni fun (Provenance a), AsTypeErrorExt e uni (Provenance a), AsError e uni fun (Provenance a), MonadError e m, MonadQuote m, Ord a, Typecheckable uni fun, GEq uni, PrettyUni uni, Pretty fun, Pretty a)
- data Error uni fun a
- = CompilationError !a !Text
- | UnsupportedError !a !Text
- | OptionsError !Text
- | PLCError !(Error uni fun a)
- | PLCTypeError !(TypeError (Term TyName Name uni fun ()) uni fun a)
- | PIRTypeError !(TypeErrorExt uni a)
- class AsError r uni fun a | r → uni fun a where
- _Error ∷ Prism' r (Error uni fun a)
- _CompilationError ∷ Prism' r (a, Text)
- _UnsupportedError ∷ Prism' r (a, Text)
- _OptionsError ∷ Prism' r Text
- _PLCError ∷ Prism' r (Error uni fun a)
- _PLCTypeError ∷ Prism' r (TypeError (Term TyName Name uni fun ()) uni fun a)
- _PIRTypeError ∷ Prism' r (TypeErrorExt uni a)
- class AsTypeError r term (uni ∷ Type → Type) fun ann | r → term uni fun ann where
- _TypeError ∷ Prism' r (TypeError term uni fun ann)
- _KindMismatch ∷ Prism' r (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ())
- _TypeMismatch ∷ Prism' r (ann, term, ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ()))
- _TyNameMismatch ∷ Prism' r (ann, TyName, TyName)
- _NameMismatch ∷ Prism' r (ann, Name, Name)
- _FreeTypeVariableE ∷ Prism' r (ann, TyName)
- _FreeVariableE ∷ Prism' r (ann, Name)
- _UnknownBuiltinFunctionE ∷ Prism' r (ann, fun)
- class AsTypeErrorExt r uni ann | r → uni ann where
- _TypeErrorExt ∷ Prism' r (TypeErrorExt uni ann)
- _MalformedDataConstrResType ∷ Prism' r (ann, Type TyName uni ann)
- data Provenance a
- = Original a
- | LetBinding Recursivity (Provenance a)
- | TermBinding String (Provenance a)
- | TypeBinding String (Provenance a)
- | DatatypeComponent DatatypeComponent (Provenance a)
- | MultipleSources (Set (Provenance a))
- data DatatypeComponent
- noProvenance ∷ Provenance a
- data CompilationOpts a = CompilationOpts {
- _coOptimize ∷ Bool
- _coTypecheck ∷ Bool
- _coPedantic ∷ Bool
- _coVerbose ∷ Bool
- _coDebug ∷ Bool
- _coDatatypes ∷ DatatypeCompilationOpts
- _coMaxSimplifierIterations ∷ Int
- _coDoSimplifierUnwrapCancel ∷ Bool
- _coDoSimplifierCaseReduce ∷ Bool
- _coDoSimplifierRewrite ∷ Bool
- _coDoSimplifierBeta ∷ Bool
- _coDoSimplifierInline ∷ Bool
- _coDoSimplifierKnownCon ∷ Bool
- _coDoSimplifierCaseOfCase ∷ Bool
- _coDoSimplifierEvaluateBuiltins ∷ Bool
- _coDoSimplifierStrictifyBindings ∷ Bool
- _coDoSimplifierRemoveDeadBindings ∷ Bool
- _coInlineHints ∷ InlineHints Name (Provenance a)
- _coInlineConstants ∷ Bool
- _coProfile ∷ Bool
- _coRelaxedFloatin ∷ Bool
- _coCaseOfCaseConservative ∷ Bool
- _coPreserveLogging ∷ Bool
- coOptimize ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coTypecheck ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coPedantic ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coVerbose ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDebug ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coMaxSimplifierIterations ∷ ∀ a. Lens' (CompilationOpts a) Int
- coDoSimplifierUnwrapCancel ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierBeta ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierInline ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierEvaluateBuiltins ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierStrictifyBindings ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierRewrite ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDoSimplifierKnownCon ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coInlineHints ∷ ∀ a a. Lens (CompilationOpts a) (CompilationOpts a) (InlineHints Name (Provenance a)) (InlineHints Name (Provenance a))
- coProfile ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coRelaxedFloatin ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coCaseOfCaseConservative ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coPreserveLogging ∷ ∀ a. Lens' (CompilationOpts a) Bool
- coDatatypes ∷ ∀ a. Lens' (CompilationOpts a) DatatypeCompilationOpts
- dcoStyle ∷ Iso' DatatypeCompilationOpts DatatypeStyle
- data DatatypeStyle
- defaultCompilationOpts ∷ CompilationOpts a
- data CompilationCtx uni fun a
- ccOpts ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (CompilationOpts a)
- ccEnclosing ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (Provenance a)
- ccTypeCheckConfig ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (PirTCConfig uni fun)
- ccBuiltinsInfo ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (BuiltinsInfo uni fun)
- ccBuiltinCostModel ∷ ∀ uni fun a. Lens' (CompilationCtx uni fun a) (CostingPart uni fun)
- data PirTCConfig uni fun = PirTCConfig {}
- data AllowEscape
- toDefaultCompilationCtx ∷ (Default (BuiltinsInfo uni fun), Default (CostingPart uni fun), Default (RewriteRules uni fun)) ⇒ TypeCheckConfig uni fun → CompilationCtx uni fun a
- runCompilerPass ∷ (Compiling m e 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)
- simplifier ∷ Compiling m e uni fun a ⇒ m (Pass m TyName Name uni fun (Provenance a))
Documentation
compileProgram ∷ Compiling m e uni fun a ⇒ Program TyName Name uni fun a → m (PLCProgram uni fun a) Source #
compileToReadable ∷ ∀ m e uni fun a b. (Compiling m e 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 e uni fun a b. (Compiling m e 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 e uni fun a = (Monad m, MonadReader (CompilationCtx uni fun a) m, AsTypeError e (Term TyName Name uni fun ()) uni fun (Provenance a), AsTypeErrorExt e uni (Provenance a), AsError e uni fun (Provenance a), MonadError e m, MonadQuote m, Ord a, Typecheckable uni fun, GEq uni, PrettyUni uni, Pretty fun, Pretty a) Source #
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
class AsError r uni fun a | r → uni fun a where Source #
_Error ∷ Prism' r (Error uni fun a) Source #
_CompilationError ∷ Prism' r (a, Text) Source #
_UnsupportedError ∷ Prism' r (a, Text) Source #
_OptionsError ∷ Prism' r Text Source #
_PLCError ∷ Prism' r (Error uni fun a) Source #
_PLCTypeError ∷ Prism' r (TypeError (Term TyName Name uni fun ()) uni fun a) Source #
_PIRTypeError ∷ Prism' r (TypeErrorExt uni a) Source #
Instances
AsError (Error uni fun a) uni fun a Source # | |
Defined in PlutusIR.Error _Error ∷ Prism' (Error uni fun a) (Error uni fun a) Source # _CompilationError ∷ Prism' (Error uni fun a) (a, Text) Source # _UnsupportedError ∷ Prism' (Error uni fun a) (a, Text) Source # _OptionsError ∷ Prism' (Error uni fun a) Text Source # _PLCError ∷ Prism' (Error uni fun a) (Error0 uni fun a) Source # _PLCTypeError ∷ Prism' (Error uni fun a) (TypeError (Term TyName Name uni fun ()) uni fun a) Source # _PIRTypeError ∷ Prism' (Error uni fun a) (TypeErrorExt uni a) Source # |
class AsTypeError r term (uni ∷ Type → Type) fun ann | r → term uni fun ann where Source #
_TypeError ∷ Prism' r (TypeError term uni fun ann) Source #
_KindMismatch ∷ Prism' r (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source #
_TypeMismatch ∷ Prism' r (ann, term, ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source #
_TyNameMismatch ∷ Prism' r (ann, TyName, TyName) Source #
_NameMismatch ∷ Prism' r (ann, Name, Name) Source #
_FreeTypeVariableE ∷ Prism' r (ann, TyName) Source #
_FreeVariableE ∷ Prism' r (ann, Name) Source #
_UnknownBuiltinFunctionE ∷ Prism' r (ann, fun) Source #
Instances
AsTypeError (Error uni fun ann) (Term TyName Name uni fun ()) uni fun ann | |
Defined in PlutusCore.Error _TypeError ∷ Prism' (Error uni fun ann) (TypeError (Term TyName Name uni fun ()) uni fun ann) Source # _KindMismatch ∷ Prism' (Error uni fun ann) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source # _TypeMismatch ∷ Prism' (Error uni fun ann) (ann, Term TyName Name uni fun (), ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source # _TyNameMismatch ∷ Prism' (Error uni fun ann) (ann, TyName, TyName) Source # _NameMismatch ∷ Prism' (Error uni fun ann) (ann, Name, Name) Source # _FreeTypeVariableE ∷ Prism' (Error uni fun ann) (ann, TyName) Source # _FreeVariableE ∷ Prism' (Error uni fun ann) (ann, Name) Source # _UnknownBuiltinFunctionE ∷ Prism' (Error uni fun ann) (ann, fun) Source # | |
AsTypeError (Error uni fun ann) (Term TyName Name uni fun ()) uni fun ann Source # | |
Defined in PlutusIR.Compiler.Error _TypeError ∷ Prism' (Error uni fun ann) (TypeError (Term TyName Name uni fun ()) uni fun ann) Source # _KindMismatch ∷ Prism' (Error uni fun ann) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source # _TypeMismatch ∷ Prism' (Error uni fun ann) (ann, Term TyName Name uni fun (), ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source # _TyNameMismatch ∷ Prism' (Error uni fun ann) (ann, TyName, TyName) Source # _NameMismatch ∷ Prism' (Error uni fun ann) (ann, Name, Name) Source # _FreeTypeVariableE ∷ Prism' (Error uni fun ann) (ann, TyName) Source # _FreeVariableE ∷ Prism' (Error uni fun ann) (ann, Name) Source # _UnknownBuiltinFunctionE ∷ Prism' (Error uni fun ann) (ann, fun) Source # | |
AsTypeError (Error uni fun a) (Term TyName Name uni fun ()) uni fun a Source # | |
Defined in PlutusIR.Error _TypeError ∷ Prism' (Error uni fun a) (TypeError (Term TyName Name uni fun ()) uni fun a) Source # _KindMismatch ∷ Prism' (Error uni fun a) (a, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source # _TypeMismatch ∷ Prism' (Error uni fun a) (a, Term TyName Name uni fun (), ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source # _TyNameMismatch ∷ Prism' (Error uni fun a) (a, TyName, TyName) Source # _NameMismatch ∷ Prism' (Error uni fun a) (a, Name, Name) Source # _FreeTypeVariableE ∷ Prism' (Error uni fun a) (a, TyName) Source # _FreeVariableE ∷ Prism' (Error uni fun a) (a, Name) Source # _UnknownBuiltinFunctionE ∷ Prism' (Error uni fun a) (a, fun) Source # | |
AsTypeError (TypeError term uni fun ann) term uni fun ann | |
Defined in PlutusCore.Error _TypeError ∷ Prism' (TypeError term uni fun ann) (TypeError term uni fun ann) Source # _KindMismatch ∷ Prism' (TypeError term uni fun ann) (ann, Type TyName uni (), ExpectedShapeOr (Kind ()), Kind ()) Source # _TypeMismatch ∷ Prism' (TypeError term uni fun ann) (ann, term, ExpectedShapeOr (Type TyName uni ()), Normalized (Type TyName uni ())) Source # _TyNameMismatch ∷ Prism' (TypeError term uni fun ann) (ann, TyName, TyName) Source # _NameMismatch ∷ Prism' (TypeError term uni fun ann) (ann, Name, Name) Source # _FreeTypeVariableE ∷ Prism' (TypeError term uni fun ann) (ann, TyName) Source # _FreeVariableE ∷ Prism' (TypeError term uni fun ann) (ann, Name) Source # _UnknownBuiltinFunctionE ∷ Prism' (TypeError term uni fun ann) (ann, fun) Source # |
class AsTypeErrorExt r uni ann | r → uni ann where Source #
_TypeErrorExt ∷ Prism' r (TypeErrorExt uni ann) Source #
_MalformedDataConstrResType ∷ Prism' r (ann, Type TyName uni ann) Source #
Instances
AsTypeErrorExt (TypeErrorExt uni ann) uni ann Source # | |
Defined in PlutusIR.Error _TypeErrorExt ∷ Prism' (TypeErrorExt uni ann) (TypeErrorExt uni ann) Source # _MalformedDataConstrResType ∷ Prism' (TypeErrorExt uni ann) (ann, Type TyName uni ann) Source # | |
AsTypeErrorExt (Error uni fun a) uni a Source # | |
Defined in PlutusIR.Error _TypeErrorExt ∷ Prism' (Error uni fun a) (TypeErrorExt uni a) Source # _MalformedDataConstrResType ∷ Prism' (Error uni fun a) (a, Type TyName uni a) 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.
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
data DatatypeComponent Source #
Instances
data CompilationOpts a Source #
CompilationOpts | |
|
Instances
Show (CompilationOpts a) Source # | |
Defined in PlutusIR.Compiler.Types |
coOptimize ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coTypecheck ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coPedantic ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coMaxSimplifierIterations ∷ ∀ a. Lens' (CompilationOpts a) Int Source #
coDoSimplifierUnwrapCancel ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierBeta ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierInline ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierEvaluateBuiltins ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierStrictifyBindings ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierRewrite ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDoSimplifierKnownCon ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coInlineHints ∷ ∀ a a. Lens (CompilationOpts a) (CompilationOpts a) (InlineHints Name (Provenance a)) (InlineHints Name (Provenance a)) Source #
coRelaxedFloatin ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coCaseOfCaseConservative ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coPreserveLogging ∷ ∀ a. Lens' (CompilationOpts a) Bool Source #
coDatatypes ∷ ∀ a. Lens' (CompilationOpts a) DatatypeCompilationOpts Source #
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]
Instances
Read DatatypeStyle Source # | |
Defined in PlutusIR.Compiler.Types | |
Show DatatypeStyle Source # | |
Defined in PlutusIR.Compiler.Types | |
Eq DatatypeStyle Source # | |
Defined in PlutusIR.Compiler.Types (==) ∷ DatatypeStyle → DatatypeStyle → Bool Source # (/=) ∷ DatatypeStyle → DatatypeStyle → Bool Source # | |
Pretty DatatypeStyle Source # | |
Defined in PlutusIR.Compiler.Types pretty ∷ DatatypeStyle → Doc ann Source # prettyList ∷ [DatatypeStyle] → Doc ann Source # |
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
Instances
HasKindCheckConfig (PirTCConfig uni fun) Source # | |
Defined in PlutusIR.Compiler.Types kindCheckConfig ∷ Lens' (PirTCConfig uni fun) KindCheckConfig Source # kccHandleNameMismatches ∷ Lens' (PirTCConfig uni fun) HandleNameMismatches Source # | |
HasTypeCheckConfig (PirTCConfig uni fun) uni fun Source # | |
Defined in PlutusIR.Compiler.Types typeCheckConfig ∷ Lens' (PirTCConfig uni fun) (TypeCheckConfig uni fun) Source # tccKindCheckConfig ∷ Lens' (PirTCConfig uni fun) KindCheckConfig Source # tccBuiltinTypes ∷ Lens' (PirTCConfig uni fun) (BuiltinTypes uni fun) Source # |
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.
toDefaultCompilationCtx ∷ (Default (BuiltinsInfo uni fun), Default (CostingPart uni fun), Default (RewriteRules uni fun)) ⇒ TypeCheckConfig uni fun → CompilationCtx uni fun a Source #
runCompilerPass ∷ (Compiling m e 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 #
simplifier ∷ Compiling m e uni fun a ⇒ m (Pass m TyName Name uni fun (Provenance a)) Source #