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