getEvent Doubts

Andre W B Furtado aw@free.elogica.com.br
Wed, 28 Mar 2001 02:37:05 -0300


This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C0B72F.FA8770A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

[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 =3D MkWindow {=20
    win     :: GLUT.Window,  -- the real window
    events  :: Events  -- the event stream
    }

And in Hugs Graphics Library the "Window" is defined as:

data Window =3D MkWindow {
    wnd     :: WND,          -- the real window
    events  :: Events,     -- the event stream
    graphic :: IORef (Draw ())  -- the current graphic
    }

Thanks,
Andre

------=_NextPart_000_0010_01C0B72F.FA8770A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>
<DIV>[Sorry about the previous email subject :) ]</DIV>
<DIV>&nbsp;</DIV>
<DIV>In&nbsp;Hugs Graphics Library,&nbsp;many procedures call =
the&nbsp;function=20
getEvent&nbsp;with&nbsp;a Window as&nbsp;the parameter. But getEvent is =
defined=20
as below:</DIV>
<DIV>&nbsp;</DIV>
<DIV>getEvent :: Events -&gt; IO Event</DIV>
<DIV>&nbsp;</DIV>
<DIV>How does this work? I've tryied to do something similar&nbsp;and =
got the=20
following error message (in GHC):</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; Couldn't match `Events' against=20
`Window'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expected type:=20
Events<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Inferred type:=20
Window<BR>&nbsp;&nbsp;&nbsp; In the first argument of `getEvent', namely =

`w'<BR>&nbsp;&nbsp;&nbsp; In a do statement: e &lt;- getEvent =
w<BR></DIV>
<DIV>In time: my "Window" is defined as following</DIV>
<DIV>&nbsp;</DIV>
<DIV>data Window =3D MkWindow { <BR>&nbsp;&nbsp;&nbsp; =
win&nbsp;&nbsp;&nbsp;&nbsp;=20
:: GLUT.Window,&nbsp; -- the real window<BR>&nbsp;&nbsp;&nbsp; =
events&nbsp; ::=20
Events&nbsp; -- the event stream<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>And in Hugs Graphics Library the "Window" is defined as:</DIV>
<DIV>&nbsp;</DIV>
<DIV>data Window =3D MkWindow {</DIV>
<DIV>&nbsp;&nbsp;&nbsp; wnd&nbsp;&nbsp;&nbsp;&nbsp; ::=20
WND,&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; -- the real=20
window<BR>&nbsp;&nbsp;&nbsp; events&nbsp; :: =
Events,&nbsp;&nbsp;&nbsp;&nbsp; --=20
the event stream<BR>&nbsp;&nbsp;&nbsp; graphic :: IORef (Draw ())&nbsp; =
-- the=20
current graphic<BR>&nbsp;&nbsp;&nbsp; }<BR></DIV>
<DIV>Thanks,</DIV>
<DIV>Andre</DIV></FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0010_01C0B72F.FA8770A0--