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

Alexander Solla ajs at 2piix.com
Wed Apr 14 22:14:38 EDT 2010

On Apr 14, 2010, at 5:10 PM, Ashley Yakeley wrote:

> Worse, this rules out values of types that are not Eq.

In principle, every type is an instance of Eq, because every type  
satisfies the identity function.  Unfortunately, you can't DERIVE  
instances in general.  As you are finding out...  On the other hand,  
if you're not comparing things by equality, it hardly matters that you  
haven't defined the function (==) :: (Eq a) => a -> a -> Bool for  
whatever your a is.

Put it another way:  the existence of the identity function defines --  
conceptually, not in code -- instances for Eq.  In particular, note  
that the extension of the identify function is a set of the form  
(value, value) for EVERY value in the type.  A proof that (id x) is x  
is a proof that x = x.

More information about the Haskell-Cafe mailing list