Haskell Hierarchical Libraries (base package)ContentsIndex
GHC.Enum
Portability non-portable (GHC extensions)
Stability internal
Maintainer cvs-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 where

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 :: a
maxBound :: a
Instances
Bounded CChar
Bounded CSChar
Bounded CUChar
Bounded CShort
Bounded CUShort
Bounded CInt
Bounded CUInt
Bounded CLong
Bounded CULong
Bounded CLLong
Bounded CULLong
Bounded CPtrdiff
Bounded CSize
Bounded CWchar
Bounded CSigAtomic
Bounded ()
(Bounded a, Bounded b) => Bounded (a, b)
(Bounded a, Bounded b, Bounded c) => Bounded (a, b, c)
(Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d)
Bounded Bool
Bounded Ordering
Bounded Char
Bounded Int
Bounded Int8
Bounded Int16
Bounded Int32
Bounded Int64
Bounded Word
Bounded Word8
Bounded Word16
Bounded Word32
Bounded Word64
Bounded CIno
Bounded CMode
Bounded COff
Bounded CPid
Bounded CSsize
Bounded CGid
Bounded CNlink
Bounded CUid
Bounded CTcflag
Bounded CRLim
Bounded Fd
Bounded Month
Bounded Day
class Enum a where

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); see Chapter 10 of the Haskell Report.

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 -> a
the successor of a value. For numeric types, succ adds 1.
pred :: a -> a
the predecessor of a value. For numeric types, pred subtracts 1.
toEnum :: Int -> a
Convert from an Int.
fromEnum :: a -> Int
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]
Used in Haskell's translation of [n..].
enumFromThen :: a -> a -> [a]
Used in Haskell's translation of [n,n'..].
enumFromTo :: a -> a -> [a]
Used in Haskell's translation of [n..m].
enumFromThenTo :: a -> a -> a -> [a]
Used in Haskell's translation of [n,n'..m].
Instances
Enum CChar
Enum CSChar
Enum CUChar
Enum CShort
Enum CUShort
Enum CInt
Enum CUInt
Enum CLong
Enum CULong
Enum CLLong
Enum CULLong
Enum CFloat
Enum CDouble
Enum CLDouble
Enum CPtrdiff
Enum CSize
Enum CWchar
Enum CSigAtomic
Enum CClock
Enum CTime
Enum ()
Enum Bool
Enum Ordering
Enum Char
Enum Int
Enum Float
Enum Double
Enum SeekMode
Enum IOMode
Enum Int8
Enum Int16
Enum Int32
Enum Int64
Enum Integer
Integral a => Enum (Ratio a)
Enum Word
Enum Word8
Enum Word16
Enum Word32
Enum Word64
Enum CDev
Enum CIno
Enum CMode
Enum COff
Enum CPid
Enum CSsize
Enum CGid
Enum CNlink
Enum CUid
Enum CCc
Enum CSpeed
Enum CTcflag
Enum CRLim
Enum Fd
Enum Month
Enum Day
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a]
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a]
Produced by Haddock version 0.6