Safe Haskell | Safe-Inferred |
---|---|

Language | GHC2021 |

Group definitions by their dependencies

In order to do type inference properly, we need to solve constraints in groups and in a certain order:

- The constraints expressions that depend on definitions should be solved
**after**the constraints of said definitions are solved - The constraints of expressions that depend on one another should be solved
**at the same time**

This module groups and orders definitions in order of their dependencies.

## Synopsis

- rewrite :: forall a. ParsedFile a -> File a
- type Scope = Set Var
- freeVars :: TermDef a -> Set Var
- freeVarsExpr :: MonadReader Scope m => Expr a -> m (Set Var)
- freeVarsPat :: MonadReader Scope m => (Pattern, Expr a) -> m (Set Var)
- freeVarsBlock :: MonadReader Scope m => Block a -> m (Set Var)

# Documentation

rewrite :: forall a. ParsedFile a -> File a Source #

Reorder and group the definitions in a file in order of their dependencies.

## Find dependencies

freeVars :: TermDef a -> Set Var Source #

Calculate the free variables in a definition - these are the top level definitions that this definition depends on.

freeVarsExpr :: MonadReader Scope m => Expr a -> m (Set Var) Source #

The free variables in an expression.

freeVarsPat :: MonadReader Scope m => (Pattern, Expr a) -> m (Set Var) Source #

The free variables on a single `pattern -> body`

pair.

freeVarsBlock :: MonadReader Scope m => Block a -> m (Set Var) Source #

The free variables in a block.