Safe Haskell | Safe-Inferred |
---|

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

# Arities map

emptyArities :: Ord n => Arities nSource

Empty arities context.

extendsArities :: Ord n => Arities n -> [(Bind n, Int)] -> Arities nSource

Extend map with some binders and their arities.

getArity :: Ord n => Arities n -> Bound n -> Maybe IntSource

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 nSource

Slurp out arities of imports and top-level bindings from a module.

aritiesOfPat :: Ord n => 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.