Safe Haskell | Safe |
---|
Eta.Classes.Enum
Description
The Enum
class defines operations on
sequentially ordered types
- successor :: Enum a => a -> a
- predecessor :: Enum a => a -> a
- toEnumeration :: Enum a => Int -> a
- fromEnumeration :: Enum a => a -> Int
- enumerateFrom :: Enum a => a -> [a]
- steppingEnumerateFrom :: Enum a => a -> a -> [a]
- enumerateFromTo :: Enum a => a -> a -> [a]
- steppingEnumerateFromTo :: Enum a => a -> a -> a -> [a]
- class Enum a where
- toEnum :: Enum a => Int -> a
- fromEnum :: Enum a => a -> Int
Documentation
predecessor :: Enum a => a -> a #
Predecessor of a value
>>>
predecessor 1
0
toEnumeration :: Enum a => Int -> a #
Converts an Int
into the equivalent value
of the enumeration
>>>
toEnumeration 1 :: Bool
True
fromEnumeration :: Enum a => a -> Int #
Converts a value from an enumeration into the
equivalent Int
value
>>>
fromEnumeration False
0
enumerateFrom :: Enum a => a -> [a] #
Generates a list from the beginning of the type to the end
>>>
take 4 (enumerateFrom 0)
[0,1,2,3]>>>
enumerateFrom False
[False,True]
steppingEnumerateFrom :: Enum a => a -> a -> [a] #
Generates a list from the beginning of the type to the end, with steps
>>>
take 4 (steppingEnumerateFrom 0 2)
[0,2,4,6]
enumerateFromTo :: Enum a => a -> a -> [a] #
Generates a list from the beginning of the type to the specified limit
>>>
enumerateFromTo 0 3
[0,1,2,3]
steppingEnumerateFromTo :: Enum a => a -> a -> a -> [a] #
Generates a list from the beginning of the type to the specified limit, with steps
>>>
steppingEnumerateFromTo 0 2 8
[0,2,4,6,8]
Instances
Enum Bool | |
Enum Char | |
Enum Int | |
Enum Int8 | |
Enum Int16 | |
Enum Int32 | |
Enum Int64 | |
Enum Integer | |
Enum Ordering | |
Enum Word | |
Enum () | |
Enum GeneralCategory | |
Enum SourceUnpackedness | |
Enum SourceStrictness | |
Enum DecidedStrictness | |
Enum Associativity | |
Integral a => Enum (Ratio a) | |
Enum (Proxy k s) | |
Enum (f a) => Enum (Alt k f a) | |
(~) k a b => Enum ((:~:) k a b) | |