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

Ertugrul Soeylemez es at ertes.de
Wed Apr 14 14:33:26 EDT 2010

Stefan Monnier <monnier at iro.umontreal.ca> wrote:

> 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.

What's "the same object"?  Functions and values have no identity in
Haskell.  The best you can do is to ask, whether the arguments refer to
the same thunk in memory (sharing), but as you say the answer isn't
portable.  It's also not much useful IMO.


nightmare = unsafePerformIO (getWrongWife >>= sex)

More information about the Haskell-Cafe mailing list