Copyright | (c) The University of Glasgow 1992-2002 |
---|---|
License | see libraries/base/LICENSE |
Maintainer | [email protected] |
Stability | internal |
Portability | non-portable (GHC extensions) |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
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
.
Bounded Bool | Since: base-2.1 |
Bounded Char | Since: base-2.1 |
Bounded Int | Since: base-2.1 |
Bounded Int8 | Since: base-2.1 |
Bounded Int16 | Since: base-2.1 |
Bounded Int32 | Since: base-2.1 |
Bounded Int64 | Since: base-2.1 |
Bounded Ordering | Since: base-2.1 |
Bounded Word | Since: base-2.1 |
Bounded Word8 | Since: base-2.1 |
Bounded Word16 | Since: base-2.1 |
Bounded Word32 | Since: base-2.1 |
Bounded Word64 | Since: base-2.1 |
Bounded VecCount | Since: base-4.10.0.0 |
Bounded VecElem | Since: base-4.10.0.0 |
Bounded () | Since: base-2.1 |
Bounded GeneralCategory | Since: base-2.1 |
Defined in GHC.Unicode | |
Bounded IntPtr | |
Bounded WordPtr | |
Bounded CUIntMax | |
Bounded CIntMax | |
Bounded CUIntPtr | |
Bounded CIntPtr | |
Bounded CSigAtomic | |
Defined in Foreign.C.Types | |
Bounded CWchar | |
Bounded CSize | |
Bounded CPtrdiff | |
Bounded CBool | |
Bounded CULLong | |
Bounded CLLong | |
Bounded CULong | |
Bounded CLong | |
Bounded CUInt | |
Bounded CInt | |
Bounded CUShort | |
Bounded CShort | |
Bounded CUChar | |
Bounded CSChar | |
Bounded CChar | |
Bounded DecidedStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded SourceStrictness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded SourceUnpackedness | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded Associativity | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
Bounded Any | Since: base-2.1 |
Bounded All | Since: base-2.1 |
Bounded Fd | |
Bounded CKey | |
Bounded CId | |
Bounded CFsFilCnt | |
Bounded CFsBlkCnt | |
Bounded CClockId | |
Bounded CBlkCnt | |
Bounded CBlkSize | |
Bounded CRLim | |
Bounded CTcflag | |
Bounded CUid | |
Bounded CNlink | |
Bounded CGid | |
Bounded CSsize | |
Bounded CPid | |
Bounded COff | |
Bounded CMode | |
Bounded CIno | |
Bounded CDev | |
Bounded ByteOrder | Since: base-4.11.0.0 |
Bounded a => Bounded (Product a) | Since: base-2.1 |
Bounded a => Bounded (Sum a) | Since: base-2.1 |
Bounded a => Bounded (Dual a) | Since: base-2.1 |
Bounded a => Bounded (Identity a) | Since: base-4.9.0.0 |
Bounded m => Bounded (WrappedMonoid m) | Since: base-4.9.0.0 |
Defined in Data.Semigroup | |
Bounded a => Bounded (Last a) | Since: base-4.9.0.0 |
Bounded a => Bounded (First a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Max a) | Since: base-4.9.0.0 |
Bounded a => Bounded (Min a) | Since: base-4.9.0.0 |
(Bounded a, Bounded b) => Bounded (a, b) | Since: base-2.1 |
Bounded (Proxy t) | Since: base-4.7.0.0 |
(Bounded a, Bounded b, Bounded c) => Bounded (a, b, c) | Since: base-2.1 |
a ~ b => Bounded (a :~: b) | Since: base-4.7.0.0 |
Coercible a b => Bounded (Coercion a b) | Since: base-4.7.0.0 |
(Applicative f, Bounded a) => Bounded (Ap f a) | Since: base-4.12.0.0 |
Bounded a => Bounded (Const a b) | Since: base-4.9.0.0 |
(Bounded a, Bounded b, Bounded c, Bounded d) => Bounded (a, b, c, d) | Since: base-2.1 |
a ~~ b => Bounded (a :~~: b) | Since: base-4.10.0.0 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e) => Bounded (a, b, c, d, e) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f) => Bounded (a, b, c, d, e, f) | Since: base-2.1 |
(Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Bounded g) => Bounded (a, b, c, d, e, f, g) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
(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) | Since: base-2.1 |
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:
succ maxBound
and pred minBound
should result in a runtime error.fromEnum
and toEnum
should give a runtime error if the result value is not representable in the result type. For example, toEnum 7 :: Bool
is an error.enumFrom
and enumFromThen
should be defined with an implicit bound, thus:enumFrom x = enumFromTo x maxBound enumFromThen x y = enumFromThenTo x y bound where bound | fromEnum y >= fromEnum x = maxBound | otherwise = minBound
the successor of a value. For numeric types, succ
adds 1.
the predecessor of a value. For numeric types, pred
subtracts 1.
Convert from an 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
.
Used in Haskell's translation of [n..]
with [n..] = enumFrom n
, a possible implementation being enumFrom n = n : enumFrom (succ n)
. For example:
enumFrom 4 :: [Integer] = [4,5,6,7,...]
enumFrom 6 :: [Int] = [6,7,8,9,...,maxBound :: Int]
enumFromThen :: a -> a -> [a] Source
Used in Haskell's translation of [n,n'..]
with [n,n'..] = enumFromThen n n'
, a possible implementation being enumFromThen n n' = n : n' : worker (f x) (f x n')
, worker s v = v : worker s (s v)
, x = fromEnum n' - fromEnum n
and f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y
For example:
enumFromThen 4 6 :: [Integer] = [4,6,8,10...]
enumFromThen 6 2 :: [Int] = [6,2,-2,-6,...,minBound :: Int]
enumFromTo :: a -> a -> [a] Source
Used in Haskell's translation of [n..m]
with [n..m] = enumFromTo n m
, a possible implementation being enumFromTo n m
| n <= m = n : enumFromTo (succ n) m
| otherwise = []
. For example:
enumFromTo 6 10 :: [Int] = [6,7,8,9,10]
enumFromTo 42 1 :: [Integer] = []
enumFromThenTo :: a -> a -> a -> [a] Source
Used in Haskell's translation of [n,n'..m]
with [n,n'..m] = enumFromThenTo n n' m
, a possible implementation being enumFromThenTo n n' m = worker (f x) (c x) n m
, x = fromEnum n' - fromEnum n
, c x = bool (>=) ((x 0)
f n y
| n > 0 = f (n - 1) (succ y)
| n < 0 = f (n + 1) (pred y)
| otherwise = y
and worker s c v m
| c v m = v : worker s c (s v) m
| otherwise = []
For example:
enumFromThenTo 4 2 -6 :: [Integer] = [4,2,0,-2,-4,-6]
enumFromThenTo 6 8 2 :: [Int] = []
boundedEnumFrom :: (Enum a, Bounded a) => a -> [a] Source
boundedEnumFromThen :: (Enum a, Bounded a) => a -> a -> [a] Source
toEnumError :: Show a => String -> Int -> (a, a) -> b Source
fromEnumError :: Show a => String -> a -> b Source
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.8.3/docs/html/libraries/base-4.13.0.0/GHC-Enum.html