base-3.0.2.0: Basic librariesContentsIndex
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 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
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 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 CIntPtr
Bounded CUIntPtr
Bounded CIntMax
Bounded CUIntMax
Bounded GeneralCategory
Bounded IntPtr
Bounded WordPtr
Bounded CSsize
Bounded CTcflag
Bounded CRLim
Bounded Fd
Bounded CNlink
Bounded CUid
Bounded CGid
Bounded CIno
Bounded CMode
Bounded COff
Bounded CPid
Bounded All
Bounded Any
Bounded a => Bounded (Dual a)
Bounded a => Bounded (Sum a)
Bounded a => Bounded (Product 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 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). 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 -> 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].
show/hide Instances
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a]
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a]
Produced by Haddock version 2.2.2