[GUI] Re: GUI Library Task Force
Manuel M. T. Chakravarty
chak@cse.unsw.edu.au
Fri, 28 Sep 2001 00:54:11 +1000
[redirected to the GUI mailing list]
Matt Harden <matth@mindspring.com> wrote,
> "Manuel M. T. Chakravarty" wrote:
>
> > * I am not a big fan of introducing an extra monad (`GUI' in
> > this case). It can easily become a pain in programs that
> > do a lot of "normal" IO as you have to lift all IO
> > functions to GUI.
>
> Shouldn't GUI be a typeclass (as a subclass of Monad), with IO being an
> instance of it? This gives the following benefits:
>
> o "Pure" GUI functions can reflect this in their type.
> i.e. (GUI g) => g ()
> o IO functions can use GUI features directly without lifting.
> o "Pure" GUI functions are implicitly usable in the IO monad
> They "are" IO functions.
That's an interesting idea. The main problem that I am
seeing at the moment is that the basic GUI functionality
that usually is imported from C libraries via the FFI will
be in IO. That's because foreign imports of sideeffecting
functions (which almost all basic GUI functions are) are
required to be of type `a -> IO b'. This constraints the
GUI monad to be IO or an extension of IO; unless you want to
get into some rather ugly messing around with `unsafePerformIO'.
Cheers,
Manuel