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

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable

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


Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META content=3D"text/html; charset=3Diso-8859-1" =
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV>In&nbsp;Hugs Graphics Library,&nbsp;many procedures call =
getEvent&nbsp;with&nbsp;a Window as&nbsp;the parameter. But getEvent is =
as below:</DIV>
<DIV>getEvent :: Events -&gt; IO Event</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;&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 =
<DIV>In time: my "Window" is defined as following</DIV>
<DIV>data Window =3D MkWindow { <BR>&nbsp;&nbsp;&nbsp; =
:: GLUT.Window,&nbsp; -- the real window<BR>&nbsp;&nbsp;&nbsp; =
events&nbsp; ::=20
Events&nbsp; -- the event stream<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>And in Hugs Graphics Library the "Window" is defined as:</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>