[Sorry about the previous email subject :) ] In Hugs Graphics Library, many procedures call the function getEvent with a Window as the parameter. But getEvent is defined as below: getEvent :: Events -> IO Event How does this work? I've tryied to do something similar and got the following error message (in GHC): Couldn't match `Events' against `Window' Expected type: Events Inferred type: Window In the first argument of `getEvent', namely `w' In a do statement: e <- getEvent w In time: my "Window" is defined as following data Window = MkWindow { win :: GLUT.Window, -- the real window events :: Events -- the event stream } And in Hugs Graphics Library the "Window" is defined as: data Window = MkWindow { wnd :: WND, -- the real window events :: Events, -- the event stream graphic :: IORef (Draw ()) -- the current graphic } Thanks, Andre
--- Andre W B Furtado <aw@free.elogica.com.br> wrote:
[Sorry about the previous email subject :) ]
In Hugs Graphics Library, many procedures call the function getEvent with a Window as the parameter. But getEvent is defined as below:
getEvent :: Events -> IO Event
How does this work? I've tryied to do something similar and got the following error message (in GHC):
Actually, this can't work (can it?). So there must be another getEvent :: Window -> IO Event. (.i.e. Its sort of overloaded). And so , there is at least one, in SOEGraphics.hs getEvent window = getWindowEvent window where getWindowEvent pulls out the Events from a window and calls Events.getEvent :: Events-> IO Event (The getEvent :: Events-> IO Event is imported qualified from GraphicsEvents.hs. I guess this was done to avoid defining a type class, and probably also because the end user doesnt need the Events.getEvent, or at least very much) Of course I am just speculating. I didnt write it :) __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text
Actually, this can't work (can it?). So there must be another getEvent :: Window -> IO Event. (.i.e. Its sort of overloaded). And so , there is at least one, in SOEGraphics.hs getEvent window = getWindowEvent window
Absolutely correct. The SOEGraphics interface was frozen at the time that the School of Expression (SOE) book went to the printers. The HGL interface has been updated (cleaned up and extended) since and SOEGraphics.hs is used to bridge the gap between the two interfaces. If you're using SOE, you should rely on the book as your primary source of information about the interface. If you're not using SOE, I'd recommend the HGL interface.
where getWindowEvent pulls out the Events from a window and calls Events.getEvent :: Events-> IO Event (The getEvent :: Events-> IO Event is imported qualified from GraphicsEvents.hs. I guess this was done to avoid defining a type class, and probably also because the end user doesnt need the Events.getEvent, or at least very much)
More the latter than the former. Hope this helps, -- Alastair Reid
participants (3)
-
Alastair Reid -
Andre W B Furtado -
Ronald Legere