[GUI] Another call for votes
Tue, 18 Mar 2003 17:30:44 +0000
On Tue, Mar 18, 2003 at 12:33:44PM +0100, Daan Leijen wrote:
> Hi all,
> >2) For every callback, there should be a register function.
> >The register function should return an IO action that can be used to
> >unregister the callback.
> I disagree with this design. It is very awkward to install callbacks this
> way as we
> have to maintain the "unregister" function. We can no longer use "nice"
> syntax like:
> button [on click := messageBox "hi there"]
I think this is one of the mid-level features we want to keep: A
convenient syntax, not just a bunch of IO functions like
> buttonOnClick :: IO () -> Button -> IO ()
> buttonGetOnClick :: Button -> IO (IO ())
Unregistering callbacks is useful (perhaps mandatory on X) but not used
very often. Thus most callbacks can be bound by
button [on click := messageBox "hi there"]
without any drawback, so let's keep this syntax! In case we need an
unregister function we can use something like
button [onOff click remove := messageBox "hi there"]
where remove has type MVar (IO ()). This might seem clumsy at first, but
note that you usually need to store this unregister function in your
program state anyway, so that you might be able to pass a piece of your
local state in. Furthermore if the MVar is full, the IO action could just
be added to the action in the MVar.