Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions for compiling let-bound PIR datatypes into PLC.
Synopsis
- compileDatatype ∷ Compiling m e uni fun a ⇒ Recursivity → PIRTerm uni fun a → Datatype TyName Name uni (Provenance a) → m (PIRTerm uni fun a)
- compileDatatypeDefs ∷ MonadQuote m ⇒ DatatypeCompilationOpts → Recursivity → Datatype TyName Name uni (Provenance a) → m (Def (TyVarDecl TyName (Provenance a)) (PLCRecType uni fun a), [Def (VarDecl TyName Name uni (Provenance a)) (PIRTerm uni fun a)], Def (VarDecl TyName Name uni (Provenance a)) (PIRTerm uni fun a))
- compileRecDatatypes ∷ Compiling m e uni fun a ⇒ PIRTerm uni fun a → NonEmpty (Datatype TyName Name uni (Provenance a)) → m (PIRTerm uni fun a)
- mkDatatypeValueType ∷ a → Datatype TyName Name uni a → Type TyName uni a
- mkDestructorTy ∷ MonadQuote m ⇒ Datatype TyName Name uni a → m (Type TyName uni a)
- mkScottTy ∷ MonadQuote m ⇒ ann → Datatype TyName Name uni ann → m (Type TyName uni ann)
- resultTypeName ∷ MonadQuote m ⇒ Datatype TyName Name uni a → m TyName
Documentation
compileDatatype ∷ Compiling m e uni fun a ⇒ Recursivity → PIRTerm uni fun a → Datatype TyName Name uni (Provenance a) → m (PIRTerm uni fun a) Source #
Compile a Datatype
bound with the given body.
compileDatatypeDefs ∷ MonadQuote m ⇒ DatatypeCompilationOpts → Recursivity → Datatype TyName Name uni (Provenance a) → m (Def (TyVarDecl TyName (Provenance a)) (PLCRecType uni fun a), [Def (VarDecl TyName Name uni (Provenance a)) (PIRTerm uni fun a)], Def (VarDecl TyName Name uni (Provenance a)) (PIRTerm uni fun a)) Source #
Compile a Datatype
to a triple of type-constructor, data-constructors, destructor definitions.
compileRecDatatypes ∷ Compiling m e uni fun a ⇒ PIRTerm uni fun a → NonEmpty (Datatype TyName Name uni (Provenance a)) → m (PIRTerm uni fun a) Source #
mkDatatypeValueType ∷ a → Datatype TyName Name uni a → Type TyName uni a Source #
The type of a datatype-value is of the form `[TyCon tyarg1 tyarg2 ... tyargn]`
mkDestructorTy ∷ MonadQuote m ⇒ Datatype TyName Name uni a → m (Type TyName uni a) Source #
Make the type of a destructor for a Datatype
.
mkDestructorTy List
= forall (a :: *) . List a -> forall (out_List :: *) . (out_List -> (a -> List a -> out_List) -> out_List)
mkScottTy ∷ MonadQuote m ⇒ ann → Datatype TyName Name uni ann → m (Type TyName uni ann) Source #
Make the "Scott-encoded" type for a Datatype
, with type variables free.
This is exactly the type of an eliminator function for the datatype.
mkScottTy Maybe = forall out_Maybe. out_Maybe -> (a -> out_Maybe) -> out_Maybe
resultTypeName ∷ MonadQuote m ⇒ Datatype TyName Name uni a → m TyName Source #