Safe Haskell | None |
---|
Simple code motion transformation performing common sub-expression elimination and variable hoisting. Note that the implementation is very inefficient.
The code is based on an implementation by Gergely Dévai.
- data BindDict ctx dom = BindDict {
- prjVariable :: forall a. dom a -> Maybe VarId
- prjLambda :: forall a. dom a -> Maybe VarId
- injVariable :: forall a. (Sat ctx a, Typeable a) => ASTF dom a -> VarId -> dom (Full a)
- injLambda :: forall a b. (Sat ctx a, Typeable a, Sat ctx b) => ASTF dom b -> VarId -> dom (b :-> Full (a -> b))
- injLet :: forall a b. (Sat ctx a, Sat ctx b) => ASTF dom b -> dom (a :-> ((a -> b) :-> Full b))
- codeMotion :: forall ctx dom a. (AlphaEq dom dom dom [(VarId, VarId)], MaybeWitnessSat ctx dom, Typeable a) => BindDict ctx dom -> (forall a. dom a -> Bool) -> ASTF dom a -> State VarId (ASTF dom a)
- defaultBindDict :: forall ctx dom. (Variable ctx :<: dom, Lambda ctx :<: dom, Let ctx ctx :<: dom) => BindDict ctx dom
- reifySmart :: forall ctx dom a. (Let ctx ctx :<: dom, AlphaEq dom dom (Lambda ctx :+: (Variable ctx :+: dom)) [(VarId, VarId)], MaybeWitnessSat ctx dom, Syntactic a (HODomain ctx dom)) => (forall a. (Lambda ctx :+: (Variable ctx :+: dom)) a -> Bool) -> a -> ASTF (Lambda ctx :+: (Variable ctx :+: dom)) (Internal a)
Documentation
Interface for binding constructs
BindDict | |
|
codeMotion :: forall ctx dom a. (AlphaEq dom dom dom [(VarId, VarId)], MaybeWitnessSat ctx dom, Typeable a) => BindDict ctx dom -> (forall a. dom a -> Bool) -> ASTF dom a -> State VarId (ASTF dom a)Source
Perform common sub-expression elimination and variable hoisting
defaultBindDict :: forall ctx dom. (Variable ctx :<: dom, Lambda ctx :<: dom, Let ctx ctx :<: dom) => BindDict ctx domSource
reifySmart :: forall ctx dom a. (Let ctx ctx :<: dom, AlphaEq dom dom (Lambda ctx :+: (Variable ctx :+: dom)) [(VarId, VarId)], MaybeWitnessSat ctx dom, Syntactic a (HODomain ctx dom)) => (forall a. (Lambda ctx :+: (Variable ctx :+: dom)) a -> Bool) -> a -> ASTF (Lambda ctx :+: (Variable ctx :+: dom)) (Internal a)Source
Like reify
but with common sub-expression elimination and variable
hoisting