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

PlutusTx.Plugin.Common

Synopsis

Documentation

injectAnchors :: TcGblEnv -> TcM TcGblEnv #

Wrap certain HsExprs in the typed checked module with anchor.

anchorExpr :: Id -> LHsExpr GhcTc -> LHsExpr GhcTc #

Wrap an HsExpr with anchor.

mkSimplPass :: DynFlags -> CoreToDo #

A simplifier pass, implemented by GHC

mkPluginPass :: Name -> PluginOptions -> CoreToDo #

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 = Ann) CoreM) #

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

runPluginM :: forall uni fun a. (DefaultFun CoreExpr #

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

compileMarkedExprOrDefer :: DefaultFun CoreExpr #

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 :: (Ann -> PluginM uni fun CoreExpr #

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

compileMarkedExpr :: DefaultFun CoreExpr #

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 :: forall uni fun m. (uni Ann) m, MonadIO m) => String -> PluginOptions -> CoreExpr -> m (PIRProgram uni fun, UPLCProgram uni fun) #

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.

thNameToGhcNameOrFail :: CompiledCode a #

Helper to avoid doing too much construction of Core ourselves

makePrimitiveNameInfo :: [Name] -> PluginM uni fun NameInfo #

Make a NameInfo mapping the given set of TH names to their DefaultFun #