giml-language-0.1.0.0: A purely functional programming language with emphasis on structural typing
Safe HaskellNone
LanguageHaskell2010

Language.Giml.Rewrites.PreInfer.GroupDefsByDeps

Description

Group definitions by their dependencies

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

  1. The constraints expressions that depend on definitions should be solved after the constraints of said definitions are solved
  2. 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

Documentation

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

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

Find dependencies

type Scope = Set Var Source #

The types that are bound in an expression.

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.