title: Haskell function to check if two values are identical
body: <p>In Haskell we have the function <code>(==) :: Eq a =&gt; a-&gt;a-&gt;Bool</code> which is fine for the large number of datatypes for which an instance of <code>Eq</code> can be defined.  However there are some types for which there is no reasonable way to define an instance of <code>Eq</code>.  one example is the simple function type <code>(a-&gt;b)</code></p>
  
  <p>I am looking for a function that will tell me if two values are actually the same -- not equal but identical.</p>
  
  <p>For example <code>f(id,id)</code> ==> <code>True</code>  <code>f((+),(-))</code> = False </p>
  
  <p><strong>Clarification:</strong></p>
  
  <p>I <em>don't</em> want to know if two function do the same thing. It is not possible in the general case to do so.  I want to know if I've gotten back the same thing I started with. Let me give a stripped down example:</p>
  
  <pre><code>data Foo = Foo (Foo-&gt;Foo)  --contains a function so no Eq instance
  
  x :: Foo
  x = Foo id -- or for that matter Foo undefined
  
  y :: Foo
  y = Foo (const x)
  
  a :: Foo
  a = let (Foo fy) = y
       in fy x
  </code></pre>
  
  <p>It is clear that by inspection once evaluated, <code>a</code> will be <code>x</code>.  But let's assume I don't know the function in y but I want to test if the Foo I put in is the same one I got back - that is does <code>fy x</code> give me <code>x</code>. How do I do this?</p>