Hal Daume III hdaume@ISI.EDU
Sun, 24 Feb 2002 23:24:48 -0800 (PST)

After reading your email i went to the discussion of IArray on the haskell
doc page (http://www.haskell.org/ghc/docs/latest/set/sec-iarray.html) and
am somewhat disturbed by it.  There is the introduction of the following

> class HasBounds a where
>   bounds :: Ix ix => a ix e -> (ix,ix)

which is then used in:

> class HasBounds a => IArray a e where
>   array :: Ix ix => (ix,ix) -> [(ix,e)] -> a ix e
>   (!) :: ...
>   (//) :: ...

I'm not sure what's bothering me about this, except that this HasBounds
declaration seems to be "anticipating" the IArray declaration.  That the
type of the bounds function assumes that for this type "a" which "has
bounds", there are two associated types, the index type and the element
type, seems to be reading too much into what it means to have bounds.  A
more reasonable (imo) definition would be:

> class Ix ix => HasBounds a ix | a -> ix where
>   bounds :: a -> (ix,ix)

that way, we would efine things like:

> instance Ix ix => HasBounds (Array.Array ix) ix where ...
> instance Ix ix => HasBounds (UArray ix) ix where ...

I think this makes things much cleaner (arguably it makes these instance
declarations a bit longer, but it makes HasBounds a class in its own
right; as it is, I don't see any reason why HasBounds should be its own
class and why the 'bounds' function isn't simply lumped into the IArray

Of course, this require dep types, which is unfortunate, but then again,
anyone who is using IArrays probably isn't writing Haskell 98 anyway, and
every compiler supports dep types, so... ;)

On the other hand, if using dep types is opposed, I would be in favor of
getting rid of the HasBounds class and lumping the bounds function into

Of course, that's just my opinion... :)

 - Hal

Hal Daume III

 "Computer science is no more about computers    | hdaume@isi.edu
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Fri, 22 Feb 2002, David Feuer wrote:

> What is IArray?  This seems rather mysterious to me.
> David Feuer
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users