universe-0.0: Classes for types where we know all the values

Safe HaskellSafe-Inferred

Data.Universe.Helpers

Synopsis

Documentation

This module is for functions that are useful for writing instances, but not necessarily for using them (and hence are not exported by the main module to avoid cluttering up the namespace).

universeDef :: (Bounded a, Enum a) => [a]Source

For many types, the universe should be [minBound .. maxBound]; universeDef makes it easy to make such types an instance of Universe via the snippet

 instance Universe Foo where universe = universeDef

interleave :: [[a]] -> [a]Source

Fair n-way interleaving: given a finite number of (possibly infinite) lists, produce a single list such that whenever v has finite index in one of the input lists, v also has finite index in the output list.

(+++) :: [a] -> [a] -> [a]Source

Fair 2-way interleaving.

(+*+) :: [a] -> [b] -> [(a, b)]Source

Fair 2-way Cartesian product: given two (possibly infinite) lists, produce a single list such that whenever v and w have finite indices in the input list, (v,w) has finite index in the output list.