utility-ht-0.0.17.2: Various small helper functions for Lists, Maybes, Tuples, Functions

Safe Haskell | None
Language | Haskell98

Data.Ix.Enum

Description

Implementations of `Ix` methods in terms of `Enum` methods.

For a type `T` of class `Enum` you can easily define an `Ix` instance by copying the following code into your module:

    import qualified Data.Ix.Enum as IxEnum

    instance Ix T where
       range           = IxEnum.range
       index           = IxEnum.index
       inRange         = IxEnum.inRange
       rangeSize       = IxEnum.rangeSize
       unsafeIndex     = IxEnum.unsafeIndex
       unsafeRangeSize = IxEnum.unsafeRangeSize

Synopsis

- range :: Enum a => (a, a) -> [a]
- index :: Enum a => (a, a) -> a -> Int
- unsafeIndex :: Enum a => (a, a) -> a -> Int
- inRange :: Enum a => (a, a) -> a -> Bool
- rangeSize :: Enum a => (a, a) -> Int
- unsafeRangeSize :: Enum a => (a, a) -> Int

# Documentation

range :: Enum a => (a, a) -> [a] Source #

    >>> range ('x','z')
    "xyz"
    >>> range (LT,GT)
    [LT,EQ,GT]

index :: Enum a => (a, a) -> a -> Int Source #

    >>> index ('a','z') 'e'
    4

unsafeIndex :: Enum a => (a, a) -> a -> Int Source #

    >>> unsafeIndex ('a','z') 'e'
    4

inRange :: Enum a => (a, a) -> a -> Bool Source #

    >>> inRange ('a','z') 'e'
    True
    >>> inRange ('x','z') 'a'
    False

rangeSize :: Enum a => (a, a) -> Int Source #

    >>> rangeSize ('x','z')
    3

unsafeRangeSize :: Enum a => (a, a) -> Int Source #

    >>> unsafeRangeSize ('x','z')
    3