I'm attempting to use the Gloss library's play
function, which takes an event-handling function whose first argument is of type Event
(according to the Hackage documentation). I'm working on Windows with GHC 7.6.3 and Gloss 1.8.0.1.
Here's a sketch of what I'm trying to do:
import Graphics.Gloss
type GameState = [Int]
handleInputEvent :: Event -> GameState -> GameState
handleInputEvent _ = id -- Just stubbed in for now
The compiler error is:
Not in scope: type constructor or class `Event'
If I go into WinGHCI and import Graphics.Gloss and ask it for the type signature of play
, it looks like this:
play ::
Display
-> Color
-> Int
-> world
-> (world -> Picture)
-> (gloss-1.8.0.1:Graphics.Gloss.Internals.Interface.Event.Event
-> world -> world)
-> (Float -> world -> world)
-> IO ()
I'm guessing this has something to do with the name Event
clashing with some other module, and thus not being imported in the same way as other symbols from Gloss.
How do I talk to Haskell about Gloss' Event
?
If you follow the link on Hackage in the type signature of play
, and find that Event
is exported from Graphics.Gloss.Interface.Pure.Game
, then simply import that module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With