Typo
[packages/base.git] / Data / Ix.hs
1 {-# LANGUAGE Trustworthy #-}
2
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module : Data.Ix
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
8 --
9 -- Maintainer : libraries@haskell.org
10 -- Stability : stable
11 -- Portability : portable
12 --
13 -- The 'Ix' class is used to map a contiguous subrange of values in
14 -- type onto integers. It is used primarily for array indexing
15 -- (see the array package).
16 --
17 -----------------------------------------------------------------------------
18
19 module Data.Ix
20 (
21 -- * The 'Ix' class
22 Ix
23 ( range
24 , index
25 , inRange
26 , rangeSize
27 )
28 -- Ix instances:
29 --
30 -- Ix Char
31 -- Ix Int
32 -- Ix Integer
33 -- Ix Bool
34 -- Ix Ordering
35 -- Ix ()
36 -- (Ix a, Ix b) => Ix (a, b)
37 -- ...
38
39 -- * Deriving Instances of 'Ix'
40 -- | Derived instance declarations for the class 'Ix' are only possible
41 -- for enumerations (i.e. datatypes having only nullary constructors)
42 -- and single-constructor datatypes, including arbitrarily large tuples,
43 -- whose constituent types are instances of 'Ix'.
44 --
45 -- * For an enumeration, the nullary constructors are assumed to be
46 -- numbered left-to-right with the indices being 0 to n-1 inclusive. This
47 -- is the same numbering defined by the 'Enum' class. For example, given
48 -- the datatype:
49 --
50 -- > data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet
51 --
52 -- we would have:
53 --
54 -- > range (Yellow,Blue) == [Yellow,Green,Blue]
55 -- > index (Yellow,Blue) Green == 1
56 -- > inRange (Yellow,Blue) Red == False
57 --
58 -- * For single-constructor datatypes, the derived instance declarations
59 -- are as shown for tuples in Figure 1
60 -- <http://www.haskell.org/onlinelibrary/ix.html#prelude-index>.
61
62 ) where
63
64 -- import Prelude
65
66 import GHC.Arr