[GUI] Haskell extention and Implementing Callbacks with a list

Alastair Reid alastair@reid-consulting-uk.ltd.uk
Wed, 19 Mar 2003 11:06:35 +0000


> 1) Add a haskell extention (wouldn't this be possible?) that allows
> for equality for functions.  Maybe only valid for IO() functions.
> Say we have:

> a :: IO ()

>   We know that (a == a) but a doesn't equal anything else.  This
> would make the unregister process much neater.

In general, we can only do equality on objects which are either:

a) Pure data 

   Ints, Floats, tuples and arrays of pure data, etc. - not functions.

b) Constructed in the IO monad

   For example, we can do equality checks on IORefs, MVars, etc.
   because the only way to construct these objects is by invoking
   an operation of type '... -> IO ...'.

   The reason being in the IO monad is important is that it gives us a
   handle on sharing: each invocation of an IO operation is allowed to
   return a distinct result whereas separate invocations of non-IO
   operations are required to give the same result.

At first glance, it seems easy enough to do equality on things in the
IO monad since it seems we could treat >>= and return as constructors.
The problem is that any useful IO code tends to involve conditionals,
pure expressions, etc. for which equality isn't feasible/ meaningful.

--
Alastair Reid                 alastair@reid-consulting-uk.ltd.uk  
Reid Consulting (UK) Limited  http://www.reid-consulting-uk.ltd.uk/alastair/