hermit-0.1.1.0: Haskell Equational Reasoning Model-to-Implementation Tunnel

Safe HaskellSafe-Infered

Language.HERMIT.Kure

Contents

Synopsis

KURE Modules

All the required functionality of KURE is exported here, so other modules do not need to import KURE directly.

data KureMonad a

A basic error Monad. KURE users may use either KureMonad or their own Monad(s).

Instances

Monad KureMonad 
Functor KureMonad 
Applicative KureMonad 
MonadCatch KureMonad

KureMonad is the minimal monad that can be an instance of MonadCatch.

Eq a => Eq (KureMonad a) 
Show a => Show (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

In HERMIT, Translate, Rewrite and Lens always operate on the same context and monad.

idR :: RewriteH aSource

A synonym for the identity rewrite. Convienient to avoid importing Control.Category.

Generic Data Type

data Core Source

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.

Constructors

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.

data CoreDef Source

A (potentially recursive) definition is an identifier and an expression. In GHC Core, recursive definitions are encoded as (Id, CoreExpr) pairs. This data type is isomorphic.

Constructors

Def Id CoreExpr 

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

Translate a binding group of the form: NonRec Id CoreExpr

nonRecR :: RewriteH CoreExpr -> RewriteH CoreBindSource

Rewrite the CoreExpr child of a binding group of the form: NonRec Id CoreExpr

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

Translate a recursive definition of the form: Def Id CoreExpr

defR :: RewriteH CoreExpr -> RewriteH CoreDefSource

Rewrite the CoreExpr child of a recursive definition of the form: Def Id CoreExpr

Case Alternatives

altT :: TranslateH CoreExpr a -> (AltCon -> [Id] -> a -> b) -> TranslateH CoreAlt bSource

Translate a case alternative of the form: (AltCon, [Id], CoreExpr)

altR :: RewriteH CoreExpr -> RewriteH CoreAltSource

Rewrite the CoreExpr child of a case alternative of the form: (AltCon, Id, CoreExpr)

Expressions

varT :: (Id -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Var Id

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

Translate an expression of the form: App CoreExpr CoreExpr

appAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: App CoreExpr CoreExpr

appAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: App CoreExpr CoreExpr

appOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: App CoreExpr CoreExpr

lamT :: TranslateH CoreExpr a -> (Id -> a -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Lam Id CoreExpr

lamR :: RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite the CoreExpr child of an expression of the form: Lam Id CoreExpr

letT :: TranslateH CoreBind a1 -> TranslateH CoreExpr a2 -> (a1 -> a2 -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Let CoreBind CoreExpr

letAllR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Let CoreBind CoreExpr

letAnyR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Let CoreBind CoreExpr

letOneR :: RewriteH CoreBind -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Let CoreBind CoreExpr

caseT :: TranslateH CoreExpr a1 -> (Int -> TranslateH CoreAlt a2) -> (a1 -> Id -> Type -> [a2] -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Case CoreExpr Id Type [CoreAlt]

caseAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Case CoreExpr Id Type [CoreAlt]

caseAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Case CoreExpr Id Type [CoreAlt]

caseOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreAlt) -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Case CoreExpr Id Type [CoreAlt]

castT :: TranslateH CoreExpr a -> (a -> Coercion -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Cast CoreExpr Coercion

castR :: RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite the CoreExpr child of an expression of the form: Cast CoreExpr Coercion

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

typeT :: (Type -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Type Type

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

Translate a binding group of the form: Rec [(Id, CoreExpr)]

recDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBindSource

Rewrite all children of a binding group of the form: Rec [(Id, CoreExpr)]

recDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBindSource

Rewrite any children of a binding group of the form: Rec [(Id, CoreExpr)]

recDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreBindSource

Rewrite one child of a binding group of the form: Rec [(Id, CoreExpr)]

letNonRecT :: TranslateH CoreExpr a1 -> TranslateH CoreExpr a2 -> (Id -> a1 -> a2 -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Let (NonRec Id CoreExpr) CoreExpr

letNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Let (NonRec Id CoreExpr) CoreExpr

letNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Let (NonRec Id CoreExpr) CoreExpr

letNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Let (NonRec Id CoreExpr) CoreExpr

letRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreExpr a2 -> ([a1] -> a2 -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Let (Rec [CoreDef]) CoreExpr

letRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Let (Rec [CoreDef]) CoreExpr

letRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Let (Rec [CoreDef]) CoreExpr

letRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Let (Rec [CoreDef]) CoreExpr

letRecDefT :: (Int -> TranslateH CoreExpr a1) -> TranslateH CoreExpr a2 -> ([(Id, a1)] -> a2 -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Let (Rec [(Id, CoreExpr)]) CoreExpr

letRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Let (Rec [(Id, CoreExpr)]) CoreExpr

letRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Let (Rec [(Id, CoreExpr)]) CoreExpr

letRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Let (Rec [(Id, CoreExpr)]) CoreExpr

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

Translate an expression of the form: Case CoreExpr Id Type [(AltCon, [Id], CoreExpr)]

caseAltAllR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExprSource

Rewrite all children of an expression of the form: Case CoreExpr Id Type [(AltCon, [Id], CoreExpr)]

caseAltAnyR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExprSource

Rewrite any children of an expression of the form: Case CoreExpr Id Type [(AltCon, [Id], CoreExpr)]

caseAltOneR :: RewriteH CoreExpr -> (Int -> RewriteH CoreExpr) -> RewriteH CoreExprSource

Rewrite one child of an expression of the form: Case CoreExpr Id Type [(AltCon, [Id], CoreExpr)]

Promotion Combinators

Rewrite Promotions

promoteModGutsR :: RewriteH ModGuts -> RewriteH CoreSource

Promote a rewrite on ModGuts to a rewrite on Core.

promoteProgramR :: RewriteH CoreProgram -> RewriteH CoreSource

Promote a rewrite on CoreProgram to a rewrite on Core.

promoteBindR :: RewriteH CoreBind -> RewriteH CoreSource

Promote a rewrite on CoreBind to a rewrite on Core.

promoteDefR :: RewriteH CoreDef -> RewriteH CoreSource

Promote a rewrite on CoreDef to a rewrite on Core.

promoteExprR :: RewriteH CoreExpr -> RewriteH CoreSource

Promote a rewrite on CoreExpr to a rewrite on Core.

promoteAltR :: RewriteH CoreAlt -> RewriteH CoreSource

Promote a rewrite on CoreAlt to a rewrite on Core.

Translate Promotions

promoteModGutsT :: TranslateH ModGuts b -> TranslateH Core bSource

Promote a translate on ModGuts to a translate on Core.

promoteProgramT :: TranslateH CoreProgram b -> TranslateH Core bSource

Promote a translate on CoreProgram to a translate on Core.

promoteBindT :: TranslateH CoreBind b -> TranslateH Core bSource

Promote a translate on CoreBind to a translate on Core.

promoteDefT :: TranslateH CoreDef b -> TranslateH Core bSource

Promote a translate on CoreDef to a translate on Core.

promoteExprT :: TranslateH CoreExpr b -> TranslateH Core bSource

Promote a translate on CoreExpr to a translate on Core.

promoteAltT :: TranslateH CoreAlt b -> TranslateH Core bSource

Promote a translate on CoreAlt to a translate on Core.