Safe Haskell | None |
---|---|
Language | Haskell2010 |
- externals :: [External]
- letNonRecSubstR :: MonadCatch m => Rewrite c m CoreExpr
- letNonRecSubstSafeR :: forall c m. (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, ReadBindings c, HasEmptyContext c, MonadCatch m) => Rewrite c m CoreExpr
- letSubstR :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr
- letSubstSafeR :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, ReadBindings c, HasEmptyContext c, MonadCatch m) => Rewrite c m CoreExpr
- letElimR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr
- letNonRecElimR :: MonadCatch m => Rewrite c m CoreExpr
- letRecElimR :: MonadCatch m => Rewrite c m CoreExpr
- progBindElimR :: MonadCatch m => Rewrite c m CoreProg
- progBindNonRecElimR :: MonadCatch m => Rewrite c m CoreProg
- progBindRecElimR :: MonadCatch m => Rewrite c m CoreProg
- letIntroR :: (MonadCatch m, MonadUnique m) => String -> Rewrite c m CoreExpr
- letNonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m CoreExpr
- progNonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m CoreProg
- nonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m Core
- letIntroUnfoldingR :: (BoundVars c, ReadBindings c, HasDynFlags m, HasHermitMEnv m, HasHscEnv m, MonadCatch m, MonadIO m, MonadThings m, MonadUnique m) => HermitName -> Rewrite c m CoreExpr
- letFloatAppR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatArgR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatLetR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatLamR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatCaseR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatCaseAltR :: MonadCatch m => Maybe Int -> Rewrite c m CoreExpr
- letFloatCastR :: MonadCatch m => Rewrite c m CoreExpr
- letFloatExprR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatTopR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreProg
- letFloatInR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatInAppR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatInCaseR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
- letFloatInLamR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr
- reorderNonRecLetsR :: MonadCatch m => [String] -> Rewrite c m CoreExpr
- letTupleR :: (MonadCatch m, MonadUnique m) => String -> Rewrite c m CoreExpr
- letToCaseR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, ReadBindings c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr
Rewrites on Let Expressions
Let Elimination
letNonRecSubstR :: MonadCatch m => Rewrite c m CoreExpr Source
Let (NonRec v e) body
==> body[e/v]
letNonRecSubstSafeR :: forall c m. (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, ReadBindings c, HasEmptyContext c, MonadCatch m) => Rewrite c m CoreExpr Source
Currently we always substitute types and coercions, and use a heuristic to decide whether to substitute expressions. This may need revisiting.
letSubstR :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m) => Rewrite c m CoreExpr Source
(let x = e1 in e2) ==> (e2[e1/x]), (x must not be free in e1)
letSubstSafeR :: (AddBindings c, ExtendPath c Crumb, ReadPath c Crumb, ReadBindings c, HasEmptyContext c, MonadCatch m) => Rewrite c m CoreExpr Source
As letNonRecSubstSafeR
, but attempting to convert a singleton recursive binding to a non-recursive binding first.
letElimR :: (ExtendPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr Source
letNonRecElimR :: MonadCatch m => Rewrite c m CoreExpr Source
Remove an unused non-recursive let binding.
let v = E1 in E2
==> E2
, if v
is not free in E2
letRecElimR :: MonadCatch m => Rewrite c m CoreExpr Source
Remove all unused recursive let bindings in the current group.
progBindElimR :: MonadCatch m => Rewrite c m CoreProg Source
progBindNonRecElimR :: MonadCatch m => Rewrite c m CoreProg Source
progBindRecElimR :: MonadCatch m => Rewrite c m CoreProg Source
Remove all unused bindings at the top level.
Let Introduction
letIntroR :: (MonadCatch m, MonadUnique m) => String -> Rewrite c m CoreExpr Source
e
==> let v = e in v
letNonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m CoreExpr Source
body
==> let v = e in body
progNonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m CoreProg Source
prog
==> ProgCons
(v = e) prog
nonRecIntroR :: (MonadCatch m, MonadUnique m) => String -> CoreExpr -> Rewrite c m Core Source
nonRecIntroR nm e = 'letNonRecIntroR nm e' <+ 'progNonRecIntroR nm e'
letIntroUnfoldingR :: (BoundVars c, ReadBindings c, HasDynFlags m, HasHermitMEnv m, HasHscEnv m, MonadCatch m, MonadIO m, MonadThings m, MonadUnique m) => HermitName -> Rewrite c m CoreExpr Source
Introduce a local definition for a (possibly imported) identifier. Rewrites occurences of the identifier to point to this new local definiton.
Let Floating Out
letFloatAppR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
(let v = ev in e) x
==> let v = ev in e x
letFloatArgR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
f (let v = ev in e)
==> let v = ev in f e
letFloatLetR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
let v = (let bds in e1) in e2
==> let bds in let v = e1 in e2
letFloatLamR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
( v -> let binds in e2)
==> let binds in ( v1 -> e2)
Fails if v
occurs in the RHS of binds
.
If v
is shadowed in binds, then v
will be alpha-renamed.
letFloatCaseR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
case (let bnds in e) of bndr alts
==> let bnds in (case e of bndr alts)
Fails if any variables bound in bnds
occurs in alts
.
letFloatCaseAltR :: MonadCatch m => Maybe Int -> Rewrite c m CoreExpr Source
case e of w { ... ; p -> let b = rhs in body ; ... } ==> let b = rhs in case e of { ... ; p -> body ; ... }
where no variable in p
or w
occurs freely in rhs
,
and where b
does not capture a free variable in the overall case,
and where w
is not rebound in b
.
letFloatCastR :: MonadCatch m => Rewrite c m CoreExpr Source
cast (let bnds in e) co
==> let bnds in cast e co
letFloatExprR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
Float a Let
through an expression, whatever the context.
letFloatTopR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, BoundVars c, MonadCatch m, MonadUnique m) => Rewrite c m CoreProg Source
Let Floating In
letFloatInR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
Float in a Let
if possible.
letFloatInAppR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
let v = ev in f a
==> (let v = ev in f) (let v = ev in a)
letFloatInCaseR :: (AddBindings c, BoundVars c, ExtendPath c Crumb, ReadPath c Crumb, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
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
letFloatInLamR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, MonadCatch m) => Rewrite c m CoreExpr Source
let v = ev in x -> e
==> x -> let v = ev in e
if v
does not shadow x
Miscallaneous
reorderNonRecLetsR :: MonadCatch m => [String] -> Rewrite c m CoreExpr Source
Re-order a sequence of nested non-recursive let bindings. The argument list should contain the let-bound variables, in the desired order.
letTupleR :: (MonadCatch m, MonadUnique m) => String -> Rewrite c m CoreExpr Source
Combine nested non-recursive lets into case of a tuple. E.g. let {v1 = e1 ; v2 = e2 ; v3 = e3} in body ==> case (e1,e2,e3) of {(v1,v2,v3) -> body}
letToCaseR :: (ExtendPath c Crumb, ReadPath c Crumb, AddBindings c, ReadBindings c, MonadCatch m, MonadUnique m) => Rewrite c m CoreExpr Source
let v = ev in e
==> case ev of v -> e