[Haskell-cafe] Re: instance Eq (a -> b)

Stefan Monnier monnier at iro.umontreal.ca
Wed Apr 14 14:22:00 EDT 2010

> Why isn't there an instance Eq (a -> b) ?

I guess it's because even for those cases where it can be written, it
will rarely be what you want to do, so it's better to require the
programmer to explicitly request a function-comparison than to risk
silently using such a costly operation when the programmer intended no
such thing.

While we're here, I'd be more interested in a dirty&fast comparison
operation which could look like:

    eq :: a -> a -> IO Bool

where the semantics is "if (eq x y) returns True, then x and y are the
same object, else they may be different".  Placing it in IO is not great
since its behavior really depends on the compiler rather than on the
external world, but at least it would be available.


More information about the Haskell-Cafe mailing list