Safe Haskell | Safe |
---|---|
Language | Haskell98 |
DDC.Core.Analysis.Arity
Contents
Description
Slurp out arities of function bindings. and infer arities for primitives based on their types.
For function bindings the arity is the number of outer-most lambdas in the definition.
For primitives, the arity is the number of function constructors in its type.
- type Arities n = (Map n Int, [Int])
- emptyArities :: Arities n
- extendsArities :: Ord n => Arities n -> [(Bind n, Int)] -> Arities n
- getArity :: Ord n => Arities n -> Bound n -> Maybe Int
- aritiesOfModule :: Ord n => Module a n -> Arities n
- aritiesOfLets :: Ord n => Lets a n -> Maybe [(Bind n, Int)]
- aritiesOfPat :: Pat n -> [(Bind n, Int)]
- arityFromType :: Ord n => Type n -> Maybe Int
- arityOfExp :: Ord n => Exp a n -> Maybe Int
Arities map
emptyArities :: Arities n Source #
Empty arities context.
extendsArities :: Ord n => Arities n -> [(Bind n, Int)] -> Arities n Source #
Extend map with some binders and their arities.
getArity :: Ord n => Arities n -> Bound n -> Maybe Int Source #
Look up a binder's arity from the arity map or determine it from its type in the case of primops.
Arity analysis
aritiesOfModule :: Ord n => Module a n -> Arities n Source #
Slurp out arities of imports and top-level bindings from a module.
aritiesOfPat :: Pat n -> [(Bind n, Int)] Source #
Retrieve binders from case pattern, so we can extend the arity context. We don't know anything about their values, so record as 0.