Safe Haskell | Safe-Infered |
---|
- module Language.KURE
- module Language.KURE.Injection
- data KureMonad a
- runKureMonad :: (a -> b) -> (String -> b) -> KureMonad a -> b
- fromKureMonad :: (String -> a) -> KureMonad a -> a
- type TranslateH a b = Translate Context HermitM a b
- type RewriteH a = Rewrite Context HermitM a
- type LensH a b = Lens Context HermitM a b
- idR :: RewriteH a
- data Core
- data CoreDef = Def Id CoreExpr
- modGutsT :: TranslateH CoreProgram a -> (ModGuts -> a -> b) -> TranslateH ModGuts b
- modGutsR :: RewriteH CoreProgram -> RewriteH ModGuts
- nilT :: b -> TranslateH [a] b
- consBindT :: TranslateH CoreBind a1 -> TranslateH CoreProgram a2 -> (a1 -> a2 -> b) -> TranslateH CoreProgram b
- consBindAllR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram
- consBindAnyR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram
- consBindOneR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgram
- nonRecT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreBind b
- nonRecR :: RewriteH CoreExpr -> RewriteH CoreBind
- recT :: (Int -> TranslateH CoreDef a) -> ([a] -> b) -> TranslateH CoreBind b
- recAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind
- recAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind
- recOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBind
- defT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreDef b
- defR :: RewriteH CoreExpr -> RewriteH CoreDef
- altT :: TranslateH CoreExpr a -> (AltCon -> [Id] -> a -> b) -> TranslateH CoreAlt b
- altR :: RewriteH CoreExpr -> RewriteH CoreAlt
- varT :: (Id -> b) -> TranslateH CoreExpr b
- litT :: (Literal -> b) -> TranslateH CoreExpr b
- appT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr b
- appAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- appAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- appOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- lamT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreExpr b
- lamR :: RewriteH CoreExpr -> RewriteH CoreExpr
- letT :: TranslateH CoreBind a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr b
- letAllR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr
- letAnyR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr
- letOneR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExpr
- caseT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreAlt a2) -> (a1 -> Id -> Type -> [a2] -> b) -> TranslateH CoreExpr b
- caseAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr
- caseAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr
- caseOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExpr
- castT :: TranslateH CoreExpr a -> (a -> Coercion -> b) -> TranslateH CoreExpr b
- castR :: RewriteH CoreExpr -> RewriteH CoreExpr
- tickT :: TranslateH CoreExpr a -> (CoreTickish -> a -> b) -> TranslateH CoreExpr b
- tickR :: RewriteH CoreExpr -> RewriteH CoreExpr
- typeT :: (Type -> b) -> TranslateH CoreExpr b
- coercionT :: (Coercion -> b) -> TranslateH CoreExpr b
- recDefT :: (Int -> TranslateH CoreExpr a1) -> ([(Id, a1)] -> b) -> TranslateH CoreBind b
- recDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind
- recDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind
- recDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBind
- letNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreExpr b
- letNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- letNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- letNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreExpr a2 -> ([a1] -> a2 -> b) -> TranslateH CoreExpr b
- letRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreExpr a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreExpr b
- letRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr
- letRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExpr
- consNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreProgram a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreProgram b
- consNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram
- consNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram
- consNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreProgram a2 -> ([a1] -> a2 -> b) -> TranslateH CoreProgram b
- consRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreProgram a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreProgram b
- consRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram
- consRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgram
- caseAltT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreExpr a2) -> (a1 -> Id -> Type -> [(AltCon, [Id], a2)] -> b) -> TranslateH CoreExpr b
- caseAltAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr
- caseAltAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr
- caseAltOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr
- promoteModGutsR :: RewriteH ModGuts -> RewriteH Core
- promoteProgramR :: RewriteH CoreProgram -> RewriteH Core
- promoteBindR :: RewriteH CoreBind -> RewriteH Core
- promoteDefR :: RewriteH CoreDef -> RewriteH Core
- promoteExprR :: RewriteH CoreExpr -> RewriteH Core
- promoteAltR :: RewriteH CoreAlt -> RewriteH Core
- promoteModGutsT :: TranslateH ModGuts b -> TranslateH Core b
- promoteProgramT :: TranslateH CoreProgram b -> TranslateH Core b
- promoteBindT :: TranslateH CoreBind b -> TranslateH Core b
- promoteDefT :: TranslateH CoreDef b -> TranslateH Core b
- promoteExprT :: TranslateH CoreExpr b -> TranslateH Core b
- promoteAltT :: TranslateH CoreAlt b -> TranslateH Core b
KURE Modules
All the required functionality of KURE is exported here, so other modules do not need to import KURE directly.
module Language.KURE
module Language.KURE.Injection
data KureMonad a
runKureMonad :: (a -> b) -> (String -> b) -> KureMonad a -> b
Eliminator for KureMonad
.
fromKureMonad :: (String -> a) -> KureMonad a -> a
Get the value from a KureMonad
, providing a function to handle the error case.
Synonyms
type TranslateH a b = Translate Context HermitM a bSource
A synonym for the identity rewrite. Convienient to avoid importing Control.Category.
Generic Data Type
Core is the sum type of all nodes in the AST that we wish to be able to traverse.
All Node
instances in HERMIT define their Generic
type to be Core
.
ModGutsCore ModGuts | The module. |
ProgramCore CoreProgram | A program (list of top-level bindings). |
BindCore CoreBind | A binding group. |
DefCore CoreDef | A recursive definition. |
ExprCore CoreExpr | An expression. |
AltCore CoreAlt | A case alternative. |
Congruence combinators
Modguts
modGutsT :: TranslateH CoreProgram a -> (ModGuts -> a -> b) -> TranslateH ModGuts bSource
Translate a module. Slightly different to the other congruence combinators: it passes in *all* of the original to the reconstruction function.
modGutsR :: RewriteH CoreProgram -> RewriteH ModGutsSource
Rewrite the CoreProgram
child of a module.
Program
nilT :: b -> TranslateH [a] bSource
Translate an empty list.
consBindT :: TranslateH CoreBind a1 -> TranslateH CoreProgram a2 -> (a1 -> a2 -> b) -> TranslateH CoreProgram bSource
Translate a program of the form: (CoreBind
:
CoreProgram
)
consBindAllR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite all children of a program of the form: (CoreBind
:
CoreProgram
)
consBindAnyR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite any children of a program of the form: (CoreBind
:
CoreProgram
)
consBindOneR :: RewriteH CoreBind -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite one child of a program of the form: (CoreBind
:
CoreProgram
)
Binding Groups
nonRecT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreBind bSource
recT :: (Int -> TranslateH CoreDef a) -> ([a] -> b) -> TranslateH CoreBind bSource
Translate a binding group of the form: Rec
[CoreDef
]
recAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBindSource
Rewrite all children of a binding group of the form: Rec
[CoreDef
]
recAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBindSource
Rewrite any children of a binding group of the form: Rec
[CoreDef
]
recOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreBindSource
Rewrite one child of a binding group of the form: Rec
[CoreDef
]
Recursive Definitions
defT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreDef bSource
Case Alternatives
altT :: TranslateH CoreExpr a -> (AltCon -> [Id] -> a -> b) -> TranslateH CoreAlt bSource
Expressions
litT :: (Literal -> b) -> TranslateH CoreExpr bSource
Translate an expression of the form: Lit
Literal
appT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr bSource
lamT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreExpr bSource
letT :: TranslateH CoreBind a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr bSource
caseT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreAlt a2) -> (a1 -> Id -> Type -> [a2] -> b) -> TranslateH CoreExpr bSource
castT :: TranslateH CoreExpr a -> (a -> Coercion -> b) -> TranslateH CoreExpr bSource
tickT :: TranslateH CoreExpr a -> (CoreTickish -> a -> b) -> TranslateH CoreExpr bSource
Translate an expression of the form: Tick
CoreTickish
CoreExpr
tickR :: RewriteH CoreExpr -> RewriteH CoreExprSource
Rewrite the CoreExpr
child of an expression of the form: Tick
CoreTickish
CoreExpr
coercionT :: (Coercion -> b) -> TranslateH CoreExpr bSource
Translate an expression of the form: Coercion
Coercion
Composite Congruence Combinators
recDefT :: (Int -> TranslateH CoreExpr a1) -> ([(Id, a1)] -> b) -> TranslateH CoreBind bSource
letNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreExpr bSource
letRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreExpr a2 -> ([a1] -> a2 -> b) -> TranslateH CoreExpr bSource
letRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreExpr a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreExpr bSource
consNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreProgram a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreProgram bSource
Translate a program of the form: (NonRec
Id
CoreExpr
) :
CoreProgram
consNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite all children of an expression of the form: (NonRec
Id
CoreExpr
) :
CoreProgram
consNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite any children of an expression of the form: (NonRec
Id
CoreExpr
) :
CoreProgram
consNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite one child of an expression of the form: (NonRec
Id
CoreExpr
) :
CoreProgram
consRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreProgram a2 -> ([a1] -> a2 -> b) -> TranslateH CoreProgram bSource
Translate an expression of the form: (Rec
[CoreDef
]) :
CoreProgram
consRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite all children of an expression of the form: (Rec
[CoreDef
]) :
CoreProgram
consRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite any children of an expression of the form: (Rec
[CoreDef
]) :
CoreProgram
consRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite one child of an expression of the form: (Rec
[CoreDef
]) :
CoreProgram
consRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreProgram a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreProgram bSource
Translate an expression of the form: (Rec
[(Id
, CoreExpr
)]) :
CoreProgram
consRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite all children of an expression of the form: (Rec
[(Id
, CoreExpr
)]) :
CoreProgram
consRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite any children of an expression of the form: (Rec
[(Id
, CoreExpr
)]) :
CoreProgram
consRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProgram -> RewriteH CoreProgramSource
Rewrite one child of an expression of the form: (Rec
[(Id
, CoreExpr
)]) :
CoreProgram
caseAltT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreExpr a2) -> (a1 -> Id -> Type -> [(AltCon, [Id], a2)] -> b) -> TranslateH CoreExpr bSource
Promotion Combinators
Rewrite Promotions
promoteProgramR :: RewriteH CoreProgram -> RewriteH CoreSource
Promote a rewrite on CoreProgram
to a rewrite on Core
.
Translate Promotions
promoteModGutsT :: TranslateH ModGuts b -> TranslateH Core bSource
promoteProgramT :: TranslateH CoreProgram b -> TranslateH Core bSource
Promote a translate on CoreProgram
to a translate on Core
.
promoteBindT :: TranslateH CoreBind b -> TranslateH Core bSource
promoteDefT :: TranslateH CoreDef b -> TranslateH Core bSource
promoteExprT :: TranslateH CoreExpr b -> TranslateH Core bSource
promoteAltT :: TranslateH CoreAlt b -> TranslateH Core bSource