base-3.0.2.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
Bounded Bool
Bounded Char
Bounded Int
Bounded Int8
Bounded Int16
Bounded Int32
Bounded Int64
Bounded Ordering
Bounded Word
Bounded Word8
Bounded Word16
Bounded Word32
Bounded Word64
Bounded ()
Bounded CUIntMax
Bounded CIntMax
Bounded CUIntPtr
Bounded CIntPtr
Bounded CSigAtomic
Bounded CWchar
Bounded CSize
Bounded CPtrdiff
Bounded CULLong
Bounded CLLong
Bounded CULong
Bounded CLong
Bounded CUInt
Bounded CInt
Bounded CUShort
Bounded CShort
Bounded CUChar
Bounded CSChar
Bounded CChar
Bounded GeneralCategory
Bounded IntPtr
Bounded WordPtr
Bounded Fd
Bounded CRLim
Bounded CTcflag
Bounded CUid
Bounded CNlink
Bounded CGid
Bounded CSsize
Bounded CPid
Bounded COff
Bounded CMode
Bounded CIno
Bounded Any
Bounded All
Bounded a => Bounded (Product a)
Bounded a => Bounded (Sum a)
Bounded a => Bounded (Dual a)
(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 a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded ((,,,,) a b c d e)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded ((,,,,,) a b c d e f)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded ((,,,,,,) a b c d e f g)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h) => Bounded ((,,,,,,,) a b c d e f g h)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i) => Bounded ((,,,,,,,,) a b c d e f g h i)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j) => Bounded ((,,,,,,,,,) a b c d e f g h i j)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k) => Bounded ((,,,,,,,,,,) a b c d e f g h i j k)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l) => Bounded ((,,,,,,,,,,,) a b c d e f g h i j k l)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m) => Bounded ((,,,,,,,,,,,,) a b c d e f g h i j k l m)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n) => Bounded ((,,,,,,,,,,,,,) a b c d e f g h i j k l m n)
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g, Bounded h, Bounded i, Bounded j, Bounded k, Bounded l, Bounded m, Bounded n, Bounded o) => Bounded ((,,,,,,,,,,,,,,) a b c d e f g h i j k l m n o)
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.3.0