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

Safe HaskellNone

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 KureM a

KureM is a basic error Monad. The KURE user is free to either use KureM or provide their own monad. KureM is essentially the same as (Either String a), except that the fail method produces an error in the monad, rather than invoking error. A major advantage of this is that monadic pattern match failures are caught safely.

Instances

Monad KureM 
Functor KureM 
Applicative KureM 
MonadCatch KureM

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

Eq a => Eq (KureM a) 
Show a => Show (KureM a) 

runKureM :: (a -> b) -> (String -> b) -> KureM a -> b

Eliminator for KureM.

fromKureM :: (String -> a) -> KureM a -> a

Get the value from a KureM, 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.

Congruence combinators

Modguts

modGutsT :: TranslateH CoreProg 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 CoreProg -> RewriteH ModGutsSource

Rewrite the CoreProg child of a module.

Program

progNilT :: b -> TranslateH CoreProg bSource

Translate an empty list.

progConsT :: TranslateH CoreBind a1 -> TranslateH CoreProg a2 -> (a1 -> a2 -> b) -> TranslateH CoreProg bSource

Translate a program of the form: (CoreBind : CoreProg)

progConsAllR :: RewriteH CoreBind -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite all children of a program of the form: (CoreBind : CoreProg)

progConsAnyR :: RewriteH CoreBind -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite any children of a program of the form: (CoreBind : CoreProg)

progConsOneR :: RewriteH CoreBind -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite one child of a program of the form: (CoreBind : CoreProg)

Binding Groups

nonRecT :: TranslateH CoreExpr a -> (Var -> a -> b) -> TranslateH CoreBind bSource

Translate a binding group of the form: NonRec Var CoreExpr

nonRecR :: RewriteH CoreExpr -> RewriteH CoreBindSource

Rewrite the CoreExpr child of a binding group of the form: NonRec Var 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 :: (Var -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Var Var

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 -> (Var -> a -> b) -> TranslateH CoreExpr bSource

Translate an expression of the form: Lam Var CoreExpr

lamR :: RewriteH CoreExpr -> RewriteH CoreExprSource

Rewrite the CoreExpr child of an expression of the form: Lam Var 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 -> (Var -> a1 -> a2 -> b) -> TranslateH CoreExpr bSource

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

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

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

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

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

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

Rewrite one child of an expression of the form: Let (NonRec Var 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 CoreProg a2 -> (Var -> a1 -> a2 -> b) -> TranslateH CoreProg bSource

Translate a program of the form: (NonRec Var CoreExpr) : CoreProg

consNonRecAllR :: RewriteH CoreExpr -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite all children of an expression of the form: (NonRec Var CoreExpr) : CoreProg

consNonRecAnyR :: RewriteH CoreExpr -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite any children of an expression of the form: (NonRec Var CoreExpr) : CoreProg

consNonRecOneR :: RewriteH CoreExpr -> RewriteH CoreProg -> RewriteH CoreProgSource

Rewrite one child of an expression of the form: (NonRec Var CoreExpr) : CoreProg

consRecT :: (Int -> TranslateH CoreDef a1) -> TranslateH CoreProg a2 -> ([a1] -> a2 -> b) -> TranslateH CoreProg bSource

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

consRecAllR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

consRecAnyR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

consRecOneR :: (Int -> RewriteH CoreDef) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

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

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

consRecDefAllR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

consRecDefAnyR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

consRecDefOneR :: (Int -> RewriteH CoreExpr) -> RewriteH CoreProg -> RewriteH CoreProgSource

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

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.

promoteProgR :: RewriteH CoreProg -> RewriteH CoreSource

Promote a rewrite on CoreProg 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.

promoteProgT :: TranslateH CoreProg b -> TranslateH Core bSource

Promote a translate on CoreProg 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.