YhcSource codeContentsIndex
Yhc.Core.Simplify
Synopsis
coreSimplify :: UniplateExpr a => a -> a
coreSimplifyExpr :: CoreExpr -> CoreExpr
coreSimplifyCaseCon :: CoreExpr -> CoreExpr
coreSimplifyCaseCase :: CoreExpr -> CoreExpr
coreSimplifyCaseLet :: CoreExpr -> CoreExpr
coreSimplifyExprUnique :: UniqueIdM m => CoreExpr -> m CoreExpr
coreSimplifyExprUniqueExt :: UniqueIdM m => ((CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExpr
Documentation
coreSimplify :: UniplateExpr a => a -> a
coreSimplifyExpr :: CoreExpr -> CoreExpr

Simplify a single Core Expr.

Performs NO inlining, guaranteed to run in same or better space and time. May increase code size.

Bugs lurk here, with inadvertant free variable capture. Move to a proper free variable monad and a guarantee of uniqueness

coreSimplifyCaseCon :: CoreExpr -> CoreExpr
Apply the Case (CoreCon ..) rule This rule has a serious sharing bug (doh!)
coreSimplifyCaseCase :: CoreExpr -> CoreExpr
Apply the Case (Case ..) rule
coreSimplifyCaseLet :: CoreExpr -> CoreExpr
Apply the Case (Let ..) rule
coreSimplifyExprUnique :: UniqueIdM m => CoreExpr -> m CoreExpr

Precondition: All variables must be unique

The following patterns must not occur:

CoreApp _ [] CoreLet [] _ CoreLam [] _ CorePos _ _

CoreCase on _ => on notElem {CoreCon _, CoreApp (CoreCon _) _, CoreLet _ _, CoreCase _ _} CoreApp x _ => x notElem {CoreApp _ _, CoreLet _ _, CoreCase _ _, CoreLam _ _} CoreLet bind _ => all (map snd bind) notElem {CoreLet _ _, CoreVar _}

The following should be applied if possible (and not breaking sharing):

CoreLet bind x => replaceFreeVars bind x CoreLet (CoreCase x alts) => CoreCase x (CoreLet inside each alt)

coreSimplifyExprUniqueExt :: UniqueIdM m => ((CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExpr) -> CoreExpr -> m CoreExpr

Sismplify in an extensible manner.

myfunc retransform

You should invoke retransform on all constructors you create.

Produced by Haddock version 0.8