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

Safe HaskellSafe
LanguageHaskell98

DDC.Core.Transform.Namify

Description

Rewriting of anonymous binders to named binders.

Synopsis

Documentation

class Namify c where Source #

Minimal complete definition

namify

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> c n -> State s (c n) Source #

Rewrite anonymous binders to named binders in a thing.

Instances

Namify Type Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Type n -> State s (Type n) Source #

Namify (Module a) Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Module a n -> State s (Module a n) Source #

Namify (Exp a) Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Exp a n -> State s (Exp a n) Source #

Namify (Alt a) Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Alt a n -> State s (Alt a n) Source #

Namify (Cast a) Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Cast a n -> State s (Cast a n) Source #

Namify (Witness a) Source # 

Methods

namify :: Ord n => Namifier s n -> Namifier s n -> Witness a n -> State s (Witness a n) Source #

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.

makeNamifier Source #

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.

namifyUnique Source #

Arguments

:: (Ord n, Namify c, BindStruct (c n) n) 
=> (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.