Performance question

Ketil Z. Malde
02 Oct 2002 13:20:55 +0200

At the moment, I have a user defined data type on which I have defined
some operations, instantiated (not derived) Eq and so on.  However,
for efficiency I'm storing the actual data in UArrays of Word8.

In order for everything to work, I need functions 'toW8' and 'fromW8'
to map between the data type and its representation in the array.

I gather it is impossible to hide the 'Eq' instance of Word8 and/or
redefine it, but could this be circumvented by instead of

        data Foo = F | G

        instance Eq Foo where
                F == _ = True
                _ == _ = False

defining something like

        newtype Foo = F Word8
        f, g, h :: Foo
        f = F 0
        g = F 1

and using the same instance declaration?  And will it still fit into a

(It is of course possible that, while profiling indicates otherwise,
the conversion functions have little impact in practice; i.e. the
optimizer will do away with them.)

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