[EMAIL PROTECTED] writes:
>
...
[Bruce McKenzie <[EMAIL PROTECTED]> asks if
import Array
main = print a
where
a :: Array Int Int
a = array (1,0) []
is legal ]
...
>
> The error reported by Hugs is caused by calling "Ix.rangeSize (1,0)"
> to determine how big the array is. Ix.rangeSize (1,0) calls "Ix.index
> (1,0) 0" which produces an error as required by the report.
>
> The report _doesn't_ say that you have to use rangeSize to calculate
> the size of the array (in fact, the "definition" doesn't use it) but I
> have absolutely no idea how I could calculate the size of an array
> without calling rangeSize. I'd guess that GHC uses rangeSize too but
> that they omitted the error check on their highly optimised Int instance.
>
(length . range) is used to calculate size in GHC (which you suggest
making the default for rangeSize). So I would say this is not a GHC
bug, but a feature that it avoids using `index' here :-) (And AFAIK
this is within the bounds of the Report). Agree with your points re:
Array sample implementation though.
Empty arrays are cool as long as you don't index them (printing them
is fine). BTW, GHC 0.29/2.01 has a bug in the storage manager re:
handling of empty arrays, fixed in 2.02.
--Sigbjorn