[Haskell-cafe] more gtk help

briand at aracnet.com briand at aracnet.com
Wed Aug 14 04:45:56 CEST 2013


On Mon, 12 Aug 2013 14:50:43 +0100
Claude Heiland-Allen <claude at mathr.co.uk> wrote:

> Hi Brian,
> 
> On 12/08/13 03:52, briand at aracnet.com wrote:
> ...
> >     Couldn't match expected type
> ...
> >       Gtk.on Gtk.exposeEvent glCanvas $ \ _ -> putStrLn "foo"
> ...
> > I looked up the type of Gtk.on and exposeEvent :
> ...
> > on
> >   :: object
> >      -> Signal object callback -> callback -> IO (ConnectId object)
> ...
> 
> I think you have the arguments flipped, try:
> 
> Gtk.on glCanvas Gtk.exposeEvent $ \_ -> ...
> 
> 
> As for explaining the types - as I understand it, you have an object and
> a callback, and the Signal associates the object with the callback for a
> specific event type.  The type variables occur more than once in the
> whole type for safety: the right type of callback must be provided for
> the event type, and the object must support the event type too.
> 
> 

This works

  _ <- Gtk.on glCanvas Gtk.exposeEvent $ return True


but not this:

  _ <- Gtk.on glCanvas Gtk.exposeEvent fooBar

where

fooBar = 
    do putStrLn "foo"
       return True

so then I thought, aha!, all I need to do is understand the type of "return True" and all will be revealed to me.  Well, it's this:

 Control.Monad.Trans.Reader.ReaderT
       (GHC.Ptr.Ptr Gtk.EExpose) IO Bool

just like the error message says.

Still don't know what that's supposed to be.  I'm having trouble tracking down 

Control.Monad.Trans.Reader.ReaderT







More information about the Haskell-Cafe mailing list