Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I access Graphics.Gloss Event type in Haskell?
    text
    copied!<p>I'm attempting to use the Gloss library's <code>play</code> function, which takes an event-handling function whose first argument is of type <a href="http://hackage.haskell.org/package/gloss-1.8.0.1/docs/Graphics-Gloss-Interface-Pure-Game.html#t:Event" rel="nofollow noreferrer"><code>Event</code></a> (according to the <a href="http://hackage.haskell.org/package/gloss-1.8.0.1/docs/Graphics-Gloss-Interface-Pure-Game.html" rel="nofollow noreferrer">Hackage documentation</a>). I'm working on Windows with GHC 7.6.3 and Gloss 1.8.0.1.</p> <p>Here's a sketch of what I'm trying to do:</p> <pre><code>import Graphics.Gloss type GameState = [Int] handleInputEvent :: Event -&gt; GameState -&gt; GameState handleInputEvent _ = id -- Just stubbed in for now </code></pre> <p>The compiler error is:</p> <pre><code>Not in scope: type constructor or class `Event' </code></pre> <p>If I go into WinGHCI and import Graphics.Gloss and ask it for the type signature of <code>play</code>, it looks like this:</p> <pre><code>play :: Display -&gt; Color -&gt; Int -&gt; world -&gt; (world -&gt; Picture) -&gt; (gloss-1.8.0.1:Graphics.Gloss.Internals.Interface.Event.Event -&gt; world -&gt; world) -&gt; (Float -&gt; world -&gt; world) -&gt; IO () </code></pre> <p>I'm guessing this has something to do with the name <code>Event</code> clashing with some other module, and thus not being imported in the same way as other symbols from Gloss.</p> <p>How do I talk to Haskell about Gloss' <code>Event</code>?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload