instance (Enum a) => IArray UArray a

Is there a reason why there is no instance of (Enum a) => IArray UArray a (other than that it will require OverlappingInstances and/or IncoherentInstances if e. g. UArray of Bools is used in the same code)? I have written one with the help of StackOverflow (http://stackoverflow.com/questions/8941386/), here is the source code: - UArrays.hs: http://hpaste.org/56728 - BenchmarkUArray.hs: http://hpaste.org/56729 - Makefile: http://hpaste.org/56727 Running the benchmark with +RTS -s on the UArray version shows 1,283,705,968 bytes allocated in the heap 113,304 bytes copied during GC 80,027,864 bytes maximum residency (2 sample(s)) 744,128 bytes maximum slop 155 MB total memory in use (0 MB lost due to fragmentation) versus 567,014,904 bytes allocated in the heap 962,651,888 bytes copied during GC 324,111,008 bytes maximum residency (3 sample(s)) 2,887,992 bytes maximum slop 545 MB total memory in use (0 MB lost due to fragmentation) on the boxed (Array Int Color) version. Also, boxed enum time is 1.75s and unboxed is 0.45s. The benchmark may be silly (I am not experienced in testing for Haskell performance), and I would be grateful for any tips on how to improve it to achieve more accurate measurements. Does having such thing make any sense? -- Best regards, Arefiev

On 20/01/12 16:31, Mikhail Arefiev wrote:
Is there a reason why there is no instance of (Enum a) => IArray UArray a (other than that it will require OverlappingInstances and/or IncoherentInstances if e. g. UArray of Bools is used in the same code)?
...
Does having such thing make any sense?
The problem is that there are Enum instances for things for which to/fromEnum doesn't make sense, such as Double, Float and Integer. Prelude> fromEnum (12345678901234567890 :: Integer) -6101065172474983726 You wouldn't want your Integers to be stored as Ints in an array. Twan
participants (2)
-
Mikhail Arefiev
-
Twan van Laarhoven