plutus-tx-plugin-1.60.0.0: The Plutus Tx compiler and GHC plugin
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusTx.Plugin.Common

Synopsis

Documentation

injectAnchorsTcGblEnvTcM TcGblEnv Source #

Wrap certain HsExprs in the typed checked module with anchor.

anchorExprIdLHsExpr GhcTcLHsExpr GhcTc Source #

Wrap an HsExpr with anchor.

mkSimplPassDynFlagsCoreToDo Source #

A simplifier pass, implemented by GHC

mkPluginPassNamePluginOptionsCoreToDo Source #

Our plugin works at haskell-module level granularity; the plugin looks at the module's top-level bindings for markers and compiles their right-hand-side core expressions.

type PluginM uni fun = ReaderT PluginCtx (ExceptT (CompileError uni fun Ann) CoreM) Source #

The monad where the plugin runs in for each module. It is a core->core compiler monad, called PluginM, augmented with pure errors.

runPluginM ∷ ∀ uni fun a. (PrettyUni uni, Pretty fun) ⇒ PluginCtxPluginM uni fun a → CoreM a Source #

Runs the plugin monad in a given context; throws a Ghc.Exception when compilation fails.

formatSourceSnippetIntIntIntStringDoc ann Source #

compileBindCoreBindPluginM DefaultUni DefaultFun CoreBind Source #

Compiles all the marked expressions in the given binder into PLC literals.

compileMarkedExprsCoreExprPluginM DefaultUni DefaultFun CoreExpr Source #

Compiles all the core-expressions surrounded by the marker in the given expression into PLC literals.

compileMarkedExprOrDeferStringTypeCoreExprPluginM DefaultUni DefaultFun CoreExpr Source #

Behaves the same as compileMarkedExpr, unless a compilation error occurs ; if a compilation error happens and the 'defer-errors' option is turned on, the compilation error is suppressed and the original hs expression is replaced with a haskell runtime-error expression.

emitRuntimeError ∷ (PrettyUni uni, Pretty fun) ⇒ TypeCompileError uni fun AnnPluginM uni fun CoreExpr Source #

Given an expected Haskell type a, it generates Haskell code which throws a GHC runtime error "as" 'CompiledCode a'.

compileMarkedExprStringTypeCoreExprPluginM DefaultUni DefaultFun CoreExpr Source #

Compile the core expression that is surrounded by a plc marker, and return a core expression which evaluates to the compiled plc AST as a serialized bytestring, to be injected back to the Haskell program.

runCompiler ∷ ∀ uni fun m. (uni ~ DefaultUni, fun ~ DefaultFun, MonadReader (CompileContext uni fun) m, MonadState CompileState m, MonadWriter CoverageIndex m, MonadQuote m, MonadError (CompileError uni fun Ann) m, MonadIO m) ⇒ StringPluginOptionsCoreExpr → m (PIRProgram uni fun, UPLCProgram uni fun) Source #

The GHC.Core to PIR to PLC compiler pipeline. Returns both the PIR and PLC output. It invokes the whole compiler chain: Core expr -> PIR expr -> PLC expr -> UPLC expr.

thNameToGhcNameOrFailNamePluginM uni fun Name Source #

Get the Name corresponding to the given Name, or throw an error if we can't get it.

makeByteStringLiteralByteStringPluginM uni fun CoreExpr Source #

Create a GHC Core expression that will evaluate to the given ByteString at runtime.

stripTicksCoreExprCoreExpr Source #

Strips all enclosing Ticks off an expression.

mkCompiledCode ∷ ∀ a. ByteStringByteStringByteStringCompiledCode a Source #

Helper to avoid doing too much construction of Core ourselves

makePrimitiveNameInfo ∷ [Name] → PluginM uni fun NameInfo Source #

Make a NameInfo mapping the given set of TH names to their TyThings for later reference.