Top-1.7: Constraint solving framework employed by the Helium Compiler.

Safe HaskellSafe-Infered

Top.Types.Synonym

Contents

Description

This module contains type synonyms to represent type synonyms. A collection of type synonyms can always be ordered, since (mutually) recursive type synonyms are not permitted. The ordering of type synonyms must be determined to find a minimal number of unfold steps to make two types syntactically equivalent.

Synopsis

Type synonyms

type TypeSynonyms = Map String (Int, Tps -> Tp)Source

A (unordered) collection of type synonyms is represented by a finite map of strings (the name of the type synonym) to pairs that have an int (the number of arguments of the type synonym) and a function.

type TypeSynonymOrdering = Map String IntSource

An ordering of type synonyms maps a name of a type synonym to a position in the ordering.

type OrderedTypeSynonyms = (TypeSynonymOrdering, TypeSynonyms)Source

An (unordered) collection of type synonyms, together with an ordering.

Utility functions

noOrderedTypeSynonyms :: OrderedTypeSynonymsSource

An empty collection of ordered type synonyms.

stringAsTypeSynonym :: OrderedTypeSynonymsSource

A string is a list of characters

getTypeSynonymOrdering :: TypeSynonyms -> (TypeSynonymOrdering, [[String]])Source

Order a collection of type synonyms, and return this ordering paired with sets of mutually recursive type synonyms that are detected.

Expansion of a type

expandType :: TypeSynonyms -> Tp -> TpSource

Fully expand a type in a recursive way.

expandTypeConstructor :: TypeSynonyms -> Tp -> TpSource

Fully expand the top-level type constructor.

expandToplevelTC :: OrderedTypeSynonyms -> Tp -> Maybe TpSource

Fully expand the top-level type constructor.

expandTypeConstructorOneStep :: TypeSynonyms -> Tp -> Maybe TpSource

Try to expand the top-level type constructor one step.

expandOneStepOrdered :: OrderedTypeSynonyms -> (Tp, Tp) -> Maybe (Tp, Tp)Source

Try to expand the top-level type constructor of one of the two paired Top.Types. If both top-level type constructors can be expanded, then the type synonym thast appears first in the ordering is expanded.