Instances of IArray

Ketil Z. Malde ketil@ii.uib.no
15 Feb 2002 11:26:38 +0100


Hi,

from the GHC documentation (5.17.1 in the libraries section), I get
the impression that (!) is a member of the IArray class.  While I'm
messing about with kinds and stuff getting this properly instantiated,
I get an error claiming that

EST.lhs:44:
    Class `IArray' does not have a method `!'
    In the instance declaration for `IArray EST n'

Experimenting with GHCi, I finally worked out

Prelude> :i IArray.IArray
-- ArrayBase.IArray is a class
class (ArrayBase.HasBounds a) => ArrayBase.IArray a :: (*
							-> * -> *) e where {
    ArrayBase.unsafeArray ::
	forall i. (PrelArr.Ix i) => (i, i) -> [(Int, e)] -> a i e;
    ArrayBase.unsafeAt ::
	forall i. (PrelArr.Ix i) => a i e -> Int -> e;
    ArrayBase.unsafeReplace ::
	forall i. (PrelArr.Ix i) => a i e -> [(Int, e)] -> a i e
	{- has default method -};
    ArrayBase.unsafeAccum ::
	forall e' i. (PrelArr.Ix i) =>
	(e -> e' -> e) -> a i e -> [(Int, e')] -> a i e
	{- has default method -};
    ArrayBase.unsafeAccumArray ::
	forall e' i. (PrelArr.Ix i) =>
	(e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> a i e
	{- has default method -};
    }

So, unless I'm misinterpreting something, the documentation is
incorrect? 

What I'd like to have, is Int-indexed access to my classes.  ATM,
I've solved it with my own class "Indexed" providing a (?) operator.
This is (obviously) not consistent with the standard types, and in
addition collides slightly with the implicit parameters syntax (works
if I leave a space between the ? and the index)

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants