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

Safe HaskellNone

Language.HERMIT.Primitive.Local.Let

Contents

Synopsis

Rewrites on Let Expressions

externals :: [External]Source

Externals relating to Let expressions.

letIntro :: Name -> Rewrite c HermitM CoreExprSource

e ==> (let v = e in v), name of v is provided

letFloatApp :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

(let v = ev in e) x ==> let v = ev in e x

letFloatArg :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

f (let v = ev in e) ==> let v = ev in f e

letFloatLet :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

let v = (let w = ew in ev) in e ==> let w = ew in let v = ev in e

letFloatLam :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

( v1 -> let v2 = e1 in e2) ==> let v2 = e1 in ( v1 -> e2) Fails if v1 occurs in e1. If v1 = v2 then v1 will be alpha-renamed.

letFloatCase :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

case (let bnds in e) of wild alts ==> let bnds in (case e of wild alts) Fails if any variables bound in bnds occurs in alts.

letFloatCast :: MonadCatch m => Rewrite c m CoreExprSource

cast (let bnds in e) co ==> let bnds in cast e co

letFloatExpr :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

Float a Let through an expression, whatever the context.

letFloatLetTop :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreProgSource

ProgCons (NonRec v (Let (NonRec w ew) ev)) p ==> ProgCons (NonRec w ew) (ProgCons (NonRec v ev) p)

letNonRecElim :: MonadCatch m => Rewrite c m CoreExprSource

Remove an unused non-recursive let binding. let v = E1 in E2 ==> E2, if v is not free in E2

letRecElim :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExprSource

Remove all unused recursive let bindings in the current group.

letToCase :: (ExtendPath c Crumb, AddBindings c, ReadBindings c) => Rewrite c HermitM CoreExprSource

let v = ev in e ==> case ev of v -> e

letUnfloat :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExprSource

Unfloat a Let if possible.

letUnfloatApp :: MonadCatch m => Rewrite c m CoreExprSource

let v = ev in f a ==> (let v = ev in f) (let v = ev in a)

letUnfloatCase :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExprSource

let v = ev in case s of p -> e ==> case (let v = ev in s) of p -> let v = ev in e, if v does not shadow a pattern binder in p

letUnfloatLam :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExprSource

let v = ev in x -> e ==> x -> let v = ev in e if v does not shadow x

reorderNonRecLets :: MonadCatch m => [Name] -> Rewrite c m CoreExprSource

Re-order a sequence of nested non-recursive let bindings. The argument list should contain the let-bound variables, in the desired order.