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 :: Ord n => 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 :: Ord n => Pat n -> [(Bind n, Int)]
- arityFromType :: Ord n => Type n -> Maybe Int
- arityOfExp :: Ord n => Exp a n -> Maybe Int
Extend map with some binders and their arities.
Look up a binder's arity from the arity map or determine it from its type in the case of primops.
Slurp out arities of imports and top-level bindings from a module.
Retrieve binders from case pattern, so we can extend the arity context. We don't know anything about their values, so record as 0.
Determine the arity of an expression by looking at its type. Count all the function arrows, and foralls.