简体   繁体   中英

How do I access Graphics.Gloss Event type in Haskell?

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 ?

如果您按照类型签名上Hackage链接play ,发现Event是由出口Graphics.Gloss.Interface.Pure.Game ,然后简单地导入模块。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM