
after getting the entry widget events to work as i wanted, i started looking at some other things to do, and my first attempt failed with this : Couldn't match expected type `Gtk.Signal (Gtk.Signal self0 (Gtk.EventM Gtk.EExpose Bool)) (t0 -> IO ())' with actual type `GtkGL.GLDrawingArea' In the second argument of `Gtk.on', namely `glCanvas' In the expression: Gtk.on Gtk.exposeEvent glCanvas In a stmt of a 'do' block: Gtk.on Gtk.exposeEvent glCanvas $ \ _ -> putStrLn "foo" Gtk.on Gtk.exposeEvent glCanvas $ putStrLn "foo" glCanvas is glCanvas <- GtkGL.glDrawingAreaNew glconfig I looked up the type of Gtk.on and exposeEvent : exposeEvent :: WidgetClass self => Signal self (EventM EExpose Bool) on :: object -> Signal object callback -> callback -> IO (ConnectId object) There are numerous problems starting with the type of 'callback' that I can't seem to trace in the documentation. And I can't figure out why callback is repeated... unfortunately it's not obvious what's going on. The type of the entry widget callback is much simpler, and quite a bit different, so I it's of little help. I'm having a hard time finding appropriate examples because everything seems to use the deprecated convention of on{eventType}, e.g. onExposeEvent or onButtonPress. I was hoping someone could teach me to fish and parse out the type for me and provide a simple example. Just pointing me to up-to-date examples would almost certainly be good enough, but I really need to understand the convention here, since I suspect as I try to attach events to other widget types I will see these sorts of problems again. Thanks, Brian

Hi Brian, On 12/08/13 03:52, briand@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. Claude -- http://mathr.co.uk

On Mon, 12 Aug 2013 14:50:43 +0100
Claude Heiland-Allen
Hi Brian,
On 12/08/13 03:52, briand@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

On Tue, Aug 13, 2013 at 10:45 PM,
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
In this case, all you need to know is the Control.Monad.Trans part and the IO underneath; this tells you that you can use `lift` and possibly `liftIO` to get at the IO. fooBar = do liftIO $ putStrLn "foo" return True If `liftIO` complains about a missing MonadIO instance, file a bug :) but you can also get there by using `lift` to reach it; in this case you only need it once, but for more deeply nested transformers you may need it multiple times (e.g. `lift . lift . lift $ putStrLn "foo"` for a stack of 3 transformers over IO). -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (3)
-
Brandon Allbery
-
briand@aracnet.com
-
Claude Heiland-Allen