Safe Haskell | None |
---|
- type FuncArity = (QName, Int)
- type Optimize = State OptState
- data OptState = OptState {
- optStmts :: [JsStmt]
- optUncurry :: [QName]
- runOptimizer :: ([JsStmt] -> Optimize [JsStmt]) -> [JsStmt] -> [JsStmt]
- optimizeToplevel :: [JsStmt] -> Optimize [JsStmt]
- tco :: [JsStmt] -> [JsStmt]
- stripAndUncurry :: [JsStmt] -> Optimize [JsStmt]
- walkAndStripForces :: [FuncArity] -> JsExp -> Optimize (Maybe JsExp)
- applyToExpsInStmts :: ([FuncArity] -> JsExp -> Optimize JsExp) -> [JsStmt] -> Optimize [JsStmt]
- applyToExpsInStmt :: [FuncArity] -> ([FuncArity] -> JsExp -> Optimize JsExp) -> JsStmt -> Optimize JsStmt
- collectFuncs :: [JsStmt] -> [FuncArity]
- expArity :: JsExp -> Int
- test :: IO ()
- uncurryBinding :: [JsStmt] -> QName -> Maybe JsStmt
- renameUncurried :: QName -> QName
Documentation
type FuncArity = (QName, Int)Source
The arity of a function. Arity here is defined to be the number of arguments that can be directly uncurried from a curried lambda abstraction. So x y z -> if x then (a -> a) else (a -> a) has an arity of 3, not 4.
runOptimizer :: ([JsStmt] -> Optimize [JsStmt]) -> [JsStmt] -> [JsStmt]Source
Run an optimizer, which may output additional statements.
optimizeToplevel :: [JsStmt] -> Optimize [JsStmt]Source
Perform any top-level cross-module optimizations and GO DEEP to optimize further.
stripAndUncurry :: [JsStmt] -> Optimize [JsStmt]Source
Strip redundant forcing from the whole generated code.
walkAndStripForces :: [FuncArity] -> JsExp -> Optimize (Maybe JsExp)Source
Strip redundant forcing from an application if possible.
applyToExpsInStmts :: ([FuncArity] -> JsExp -> Optimize JsExp) -> [JsStmt] -> Optimize [JsStmt]Source
Apply the given function to the top-level expressions in the given statements.
applyToExpsInStmt :: [FuncArity] -> ([FuncArity] -> JsExp -> Optimize JsExp) -> JsStmt -> Optimize JsStmtSource
Apply the given function to the top-level expressions in the given statement.
collectFuncs :: [JsStmt] -> [FuncArity]Source
Collect functions and their arity from the whole codeset.
renameUncurried :: QName -> QNameSource
Rename an uncurried copy of a curried function.