emgm-0.3.1: Extensible and Modular Generics for the MassesSource codeContentsIndex

Summary: Generic function that enumerates the values of a datatype.

enum generates a list of the values of a datatypes. It will produce all values of all supported datatypes (with only a few exceptions [1]). For datatypes that have an infinite enumeration (e.g. Integer and [a]), enum produces an infinite list.

A number of the techniques used to write enum came from a talk by Mark Jones at the 2008 Advanced Functional Programming Summer School. The authors gratefully acknowledge his contribution.

The exceptions are Float and Double. These are treated in the same way as their Enum instances are treated. The result looks like this: [0.0,-1.0,1.0,-2.0,..], thus skipping all non-integral values. Note that these may overflow, because they are unbounded.
newtype Enum a = Enum {
selEnum :: [a]
enum :: Rep Enum a => [a]
enumN :: (Integral n, Rep Enum a) => n -> [a]
empty :: Rep Enum a => a
newtype Enum a Source
The type of a generic function that takes no arguments and returns a list of some type.
selEnum :: [a]
show/hide Instances
enum :: Rep Enum a => [a]Source
Enumerate the values of a datatype. If the number of values is infinite, the result will be an infinite list. The remaining functions are derived from enum.
enumN :: (Integral n, Rep Enum a) => n -> [a]Source
Enumerate the first n values of a datatype. This is a shortcut for genericTake n (enum).
empty :: Rep Enum a => aSource
Returns the first element of the enumeration from enum. This is often called the neutral or empty value.
Produced by Haddock version 2.4.2