base-3.0.1.0: Basic librariesSource codeContentsIndex
GHC.Enum
Portabilitynon-portable (GHC extensions)
Stabilityinternal
Maintainercvs-ghc@haskell.org
Description
The Enum and Bounded classes.
Synopsis
class Bounded a where
minBound :: a
maxBound :: a
class Enum a where
succ :: a -> a
pred :: a -> a
toEnum :: Int -> a
fromEnum :: a -> Int
enumFrom :: a -> [a]
enumFromThen :: a -> a -> [a]
enumFromTo :: a -> a -> [a]
enumFromThenTo :: a -> a -> a -> [a]
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a]
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a]
Documentation
class Bounded a whereSource

The Bounded class is used to name the upper and lower limits of a type. Ord is not a superclass of Bounded since types that are not totally ordered may also have upper and lower bounds.

The Bounded class may be derived for any enumeration type; minBound is the first constructor listed in the data declaration and maxBound is the last. Bounded may also be derived for single-constructor datatypes whose constituent types are in Bounded.

Methods
minBound :: aSource
maxBound :: aSource
show/hide Instances
class Enum a whereSource

Class Enum defines operations on sequentially ordered types.

The enumFrom... methods are used in Haskell's translation of arithmetic sequences.

Instances of Enum may be derived for any enumeration type (types whose constructors have no fields). The nullary constructors are assumed to be numbered left-to-right by fromEnum from 0 through n-1. See Chapter 10 of the Haskell Report for more details.

For any type that is an instance of class Bounded as well as Enum, the following should hold:

	enumFrom     x   = enumFromTo     x maxBound
	enumFromThen x y = enumFromThenTo x y bound
	  where
	    bound | fromEnum y >= fromEnum x = maxBound
	          | otherwise                = minBound
Methods
succ :: a -> aSource
the successor of a value. For numeric types, succ adds 1.
pred :: a -> aSource
the predecessor of a value. For numeric types, pred subtracts 1.
toEnum :: Int -> aSource
Convert from an Int.
fromEnum :: a -> IntSource
Convert to an Int. It is implementation-dependent what fromEnum returns when applied to a value that is too large to fit in an Int.
enumFrom :: a -> [a]Source
Used in Haskell's translation of [n..].
enumFromThen :: a -> a -> [a]Source
Used in Haskell's translation of [n,n'..].
enumFromTo :: a -> a -> [a]Source
Used in Haskell's translation of [n..m].
enumFromThenTo :: a -> a -> a -> [a]Source
Used in Haskell's translation of [n,n'..m].
show/hide Instances
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a]Source
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a]Source
Produced by Haddock version 2.0.0.0