ddc-core-0.4.1.3: Disciplined Disciple Compiler core language and type checker.

Safe HaskellSafe-Inferred

DDC.Type.Sum

Contents

Description

Utilities for working with TypeSums.

Synopsis

Constructors

empty :: Kind n -> TypeSum nSource

Construct an empty type sum of the given kind.

singleton :: Ord n => Kind n -> Type n -> TypeSum nSource

Construct a type sum containing a single element.

union :: Ord n => TypeSum n -> TypeSum n -> TypeSum nSource

Add two type sums.

unions :: Ord n => Kind n -> [TypeSum n] -> TypeSum nSource

Union a list of TypeSums together.

insert :: Ord n => Type n -> TypeSum n -> TypeSum nSource

Insert a new element into a sum.

Conversion

toList :: TypeSum n -> [Type n]Source

Flatten out a sum, yielding a list of individual terms.

fromList :: Ord n => Kind n -> [Type n] -> TypeSum nSource

Convert a list of types to a TypeSum

Projection

kindOfSum :: TypeSum n -> Kind nSource

Take the kind of a sum.

elem :: (Eq n, Ord n) => Type n -> TypeSum n -> BoolSource

Check whether an element is a member of a sum.

  • Returns True when the first argument is $0 or !0.
  • Returns False when the first argument is another sum.
  • May return False if the first argument is miskinded but still alpha-equivalent to some component of the sum.

Deletion

delete :: Ord n => Type n -> TypeSum n -> TypeSum nSource

Delete an element from a sum.

difference :: Ord n => TypeSum n -> TypeSum n -> TypeSum nSource

Delete all members of the second sum from the first one.

Hashing

hashTyCon :: TyCon n -> Maybe TyConHashSource

Yield the TyConHash of a TyCon, or Nothing if there isn't one.

hashTyConRange :: (TyConHash, TyConHash)Source

The range of hashes that can be produced by hashTyCon.

unhashTyCon :: TyConHash -> TyCon nSource

Yield the TyCon corresponding to a TyConHash, or error if there isn't one.