ddc-core-simpl-0.3.1.1: Disciplined Disciple Compiler code transformations.

Safe HaskellSafe-Inferred

DDC.Core.Transform.Namify

Description

Rewriting of anonymous binders to named binders.

Synopsis

Documentation

class Namify c whereSource

Methods

namifySource

Arguments

:: Ord n 
=> Namifier s n

Namifier for type names (level-1)

-> Namifier s n

Namifier for exp names (level-0)

-> c n

Rewrite binders in this thing.

-> State s (c n) 

Rewrite anonymous binders to named binders in a thing.

data Namifier s n Source

Holds a function to rename binders, and the state of the renamer as we decend into the tree.

Constructors

Namifier 

Fields

namifierNew :: Env n -> Bind n -> State s n

Create a new name for this bind that is not in the given environment.

namifierEnv :: Env n

Holds the current environment during namification.

namifierStack :: [Bind n]

Stack of debruijn binders that have been rewritten during namification.

makeNamifierSource

Arguments

:: (Env n -> Bind n -> State s n)

Function to rename binders. The name chosen cannot be a member of the given

-> Env n

Starting environment of names we cannot use.

-> Namifier s n 

Construct a new namifier.

namifyUniqueSource

Arguments

:: (Ord n, Namify c, BindStruct c) 
=> (KindEnv n -> Namifier s n)

Make a namifier for level-1 names.

-> (TypeEnv n -> Namifier s n)

Make a namifier for level-0 names.

-> c n 
-> State s (c n) 

Namify a thing, not reusing names already in the program.