| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Language.Syntactic.Functional.Sharing
Contents
Description
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 InjDict sym a b = InjDict {}
- data CodeMotionInterface sym = Interface {}
- defaultInterface :: forall sym symT. (Binding :<: sym, Let :<: sym, symT ~ Typed sym) => (forall a b. ASTF symT a -> ASTF symT b -> Bool) -> (forall a. ASTF symT a -> Bool) -> CodeMotionInterface symT
- defaultInterfaceT :: forall sym symT. (BindingT :<: sym, Let :<: sym, symT ~ Typed sym) => (forall a b. ASTF symT a -> ASTF symT b -> Bool) -> (forall a. ASTF symT a -> Bool) -> CodeMotionInterface symT
- codeMotion :: forall sym m a. (Equality sym, BindingDomain sym) => CodeMotionInterface sym -> ASTF sym a -> ASTF sym a
Interface
Interface for injecting binding constructs
data CodeMotionInterface sym Source
Code motion interface
Constructors
| Interface | |
Fields
| |
Arguments
| :: (Binding :<: sym, Let :<: sym, symT ~ Typed sym) | |
| => (forall a b. ASTF symT a -> ASTF symT b -> Bool) | Can the expression represented by the first argument be shared in the second argument? |
| -> (forall a. ASTF symT a -> Bool) | Can we hoist over this expression? |
| -> CodeMotionInterface symT |
Default CodeMotionInterface for domains of the form
.Typed (... :+: Binding :+: ...)
Arguments
| :: (BindingT :<: sym, Let :<: sym, symT ~ Typed sym) | |
| => (forall a b. ASTF symT a -> ASTF symT b -> Bool) | Can the expression represented by the first argument be shared in the second argument? |
| -> (forall a. ASTF symT a -> Bool) | Can we hoist over this expression? |
| -> CodeMotionInterface symT |
Default CodeMotionInterface for domains of the form
.Typed (... :+: BindingT :+: ...)
Code motion
codeMotion :: forall sym m a. (Equality sym, BindingDomain sym) => CodeMotionInterface sym -> ASTF sym a -> ASTF sym a Source
Perform common sub-expression elimination and variable hoisting