plutus-core-0.1.0.0: Language library for Plutus Core
Safe HaskellNone
LanguageHaskell2010

PlutusIR.Compiler

Synopsis

Documentation

compileTerm :: Compiling m e uni fun a => Term TyName Name uni fun a -> m (PLCTerm uni fun a) Source #

compileToReadable :: (Compiling m e uni fun a, b ~ Provenance a) => Term TyName Name uni fun a -> m (Term 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 :: (Compiling m e uni fun a, b ~ Provenance a) => Term TyName Name uni fun b -> m (PLCTerm 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, Pretty fun, Closed uni, GShow uni, uni `Everywhere` PrettyConst, 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.

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
(GShow uni, Closed uni, Everywhere uni PrettyConst, Pretty fun, Pretty ann) => PrettyBy PrettyConfigPlc (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

prettyBy :: PrettyConfigPlc -> Error uni fun ann -> Doc ann0 Source #

prettyListBy :: PrettyConfigPlc -> [Error uni fun ann] -> Doc ann0 Source #

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

Defined in PlutusIR.Error

Methods

showsPrec :: Int -> Error uni fun ann -> ShowS Source #

show :: Error uni fun ann -> String Source #

showList :: [Error uni fun ann] -> ShowS Source #

(PrettyUni uni ann, Typeable uni, Typeable fun, Typeable ann, Pretty fun) => Exception (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

toException :: Error uni fun ann -> SomeException Source #

fromException :: SomeException -> Maybe (Error uni fun ann) Source #

displayException :: Error uni fun ann -> String Source #

(Pretty ann, Pretty fun, GShow uni, Closed uni, Everywhere uni PrettyConst) => Pretty (Error uni fun ann) Source # 
Instance details

Defined in PlutusIR.Error

Methods

pretty :: Error uni fun ann -> Doc ann0 Source #

prettyList :: [Error uni fun ann] -> Doc ann0 Source #

HasErrorCode (Error _a _b _c) Source # 
Instance details

Defined in PlutusIR.Error

Methods

errorCode :: Error _a _b _c -> ErrorCode Source #

AsFreeVariableError (Error uni fun a) Source # 
Instance details

Defined in PlutusIR.Error

AsTypeErrorExt (Error uni fun a) uni a Source # 
Instance details

Defined in PlutusIR.Error

Methods

_TypeErrorExt :: Prism' (Error uni fun a) (TypeErrorExt uni a) Source #

_MalformedDataConstrResType :: Prism' (Error uni fun a) (a, Type TyName uni a) Source #

AsError (Error uni fun a) uni fun a Source # 
Instance details

Defined in PlutusIR.Error

Methods

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

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

AsTypeError (Error uni fun a) (Term TyName Name uni fun ()) uni fun a Source # 
Instance details

Defined in PlutusIR.Error

Methods

_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 (), Kind (), Kind ()) Source #

_TypeMismatch :: Prism' (Error uni fun a) (a, Term TyName Name uni fun (), Type TyName uni (), Normalized (Type TyName uni ())) 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 #

class AsError r uni fun a | r -> uni fun a where Source #

Minimal complete definition

_Error

Instances

Instances details
AsError (Error uni fun a) uni fun a Source # 
Instance details

Defined in PlutusIR.Error

Methods

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

_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 fun ann | r -> term uni fun ann where Source #

Minimal complete definition

_TypeError

Methods

_TypeError :: Prism' r (TypeError term uni fun ann) Source #

_KindMismatch :: Prism' r (ann, Type TyName uni (), Kind (), Kind ()) Source #

_TypeMismatch :: Prism' r (ann, term, Type TyName uni (), Normalized (Type TyName uni ())) Source #

_FreeTypeVariableE :: Prism' r (ann, TyName) Source #

_FreeVariableE :: Prism' r (ann, Name) Source #

_UnknownBuiltinFunctionE :: Prism' r (ann, fun) Source #

Instances

Instances details
AsTypeError (Error uni fun ann) (Term TyName Name uni fun ()) uni fun ann Source # 
Instance details

Defined in PlutusCore.Error

Methods

_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 (), Kind (), Kind ()) Source #

_TypeMismatch :: Prism' (Error uni fun ann) (ann, Term TyName Name uni fun (), Type TyName uni (), Normalized (Type TyName uni ())) 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 # 
Instance details

Defined in PlutusIR.Error

Methods

_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 (), Kind (), Kind ()) Source #

_TypeMismatch :: Prism' (Error uni fun a) (a, Term TyName Name uni fun (), Type TyName uni (), Normalized (Type TyName uni ())) 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 Source # 
Instance details

Defined in PlutusCore.Error

Methods

_TypeError :: Prism' (TypeError term uni fun ann) (TypeError term uni fun ann) Source #

_KindMismatch :: Prism' (TypeError term uni fun ann) (ann, Type TyName uni (), Kind (), Kind ()) Source #

_TypeMismatch :: Prism' (TypeError term uni fun ann) (ann, term, Type TyName uni (), Normalized (Type TyName uni ())) 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 #

Minimal complete definition

_TypeErrorExt

Instances

Instances details
AsTypeErrorExt (TypeErrorExt uni ann) uni ann Source # 
Instance details

Defined in PlutusIR.Error

AsTypeErrorExt (Error uni fun a) uni a Source # 
Instance details

Defined in PlutusIR.Error

Methods

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

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
Eq a => Eq (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Ord a => Ord (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Show a => Show (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Ord a => Semigroup (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Pretty a => Pretty (Provenance a) Source # 
Instance details

Defined in PlutusIR.Compiler.Provenance

Methods

pretty :: Provenance a -> Doc ann Source #

prettyList :: [Provenance a] -> Doc ann Source #

data CompilationOpts a Source #

Instances

Instances details
Show (CompilationOpts a) Source # 
Instance details

Defined in PlutusIR.Compiler.Types

data CompilationCtx uni fun a Source #

ccOpts :: forall uni fun a. Lens' (CompilationCtx uni fun a) (CompilationOpts a) Source #

ccEnclosing :: forall uni fun a. Lens' (CompilationCtx uni fun a) (Provenance a) Source #

ccTypeCheckConfig :: forall uni fun a uni fun. Lens (CompilationCtx uni fun a) (CompilationCtx uni fun a) (Maybe (PirTCConfig uni fun)) (Maybe (PirTCConfig 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