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

PlutusTx.Compiler.Type

Description

Functions for compiling GHC types into PlutusCore types, as well as compiling constructors, matchers, and pattern match alternatives.

Synopsis

Documentation

compileTypeNorm ∷ CompilingDefault uni fun m ann ⇒ Type → m (PIRType uni) Source #

Compile a type, first of all normalizing it to remove type family redexes.

Generally, we need to call this whenever we are compiling a "new" type from the program. If we are compiling a part of a type we are already processing then it has likely been normalized and we can just use compileType

compileType ∷ CompilingDefault uni fun m ann ⇒ Type → m (PIRType uni) Source #

Compile a type.

compileKind ∷ Compiling uni fun m ann ⇒ Kind → m (Kind ()) Source #

getDataCons ∷ Compiling uni fun m ann ⇒ TyCon → m [DataCon] Source #

getConstructors ∷ CompilingDefault uni fun m ann ⇒ TyCon → m [PIRTerm uni fun] Source #

Get the constructors of the given TyCon as PLC terms.

getMatch ∷ CompilingDefault uni fun m ann ⇒ TyCon → m (ManualMatcher uni fun Ann) Source #

Get the matcher of the given TyCon as a PLC term.

Note: The opaque builtin check here is defensive. While opaque types don't expose constructors for explicit pattern matching, GHC optimizations could theoretically generate case expressions on these types.

getMatchInstantiated ∷ CompilingDefault uni fun m ann ⇒ Type → m (Term TyName Name uni fun Ann → Type TyName uni Ann → [Term TyName Name uni fun Ann] → Term TyName Name uni fun Ann) Source #

Get the matcher of the given Type (which must be equal to a type constructor application) as a PLC term instantiated for the type constructor argument types.

splitGhcName ∷ Name → (Maybe Module, String) Source #