我如何在Haskell中访问Graphics.Gloss事件类型?

5
我尝试使用Gloss库的play函数,该函数需要一个事件处理函数作为参数,其中第一个参数的类型是Event(根据Hackage文档)。我正在使用GHC 7.6.3和Gloss 1.8.0.1在Windows上工作。
这是我的尝试草图:
import Graphics.Gloss

type GameState = [Int]

handleInputEvent :: Event -> GameState -> GameState
handleInputEvent _ = id -- Just stubbed in for now

编译器错误为:
Not in scope: type constructor or class `Event'

如果我进入WinGHCI并导入Graphics.Gloss,然后询问play的类型签名,它会显示如下:

play ::
  Display
  -> Color
  -> Int
  -> world
  -> (world -> Picture)
  -> (gloss-1.8.0.1:Graphics.Gloss.Internals.Interface.Event.Event
      -> world -> world)
  -> (Float -> world -> world)
  -> IO ()

我猜这可能与名称Event与其他模块冲突有关,因此不能像从Gloss中导入其他符号那样进行导入。

如何让Haskell了解Gloss的Event

1个回答

1

谢谢!今晚我回家后开始查看Gloss库的代码,导入各种东西,并弄清楚了其中的问题。 - James McNeill
我没有理解文档,我猜测;在那里的play函数可以直接看到而不需要导入Graphics.Gloss.Interface.Pure.Game,所以我假设那里其它的符号也会可见。 - James McNeill
1
@user5014:是的,通常像这样的顶层模块应该重新导出它期望客户端使用的类型定义。这可能是一个疏忽。 - Jon Purdy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接