3
我仍在學習Haskell,需要類型推理的幫助!類型簽名「也許一個」不喜歡「只是[事件]」
使用包SDL和揚帕 我從FRP.Yampa.reactimate
獲得下列類型的簽名:
(Bool -> IO (DTime, Maybe a))
,我想用它來:
myInput :: Bool -> IO (DTime, Maybe [SDL.Event])
myInput isBlocking = do
event <- SDL.pollEvent
return (1, Just [event])
...
reactimate myInit myInput myOutput mySF
但它說
Couldn't match expected type `()' against inferred type `[SDL.Event]' Expected type: IO (DTime, Maybe()) Inferred type: IO (DTime, Maybe [SDL.Event]) In the second argument of `reactimate', namely `input' In the expression: reactimate initialize input output process
我以爲Maybe a
允許我使用任何東西,前夕n a SDL.Event
list? 爲什麼期望Maybe()
當型簽名實際上是Maybe a
? 爲什麼它需要一個空的元組,或者一個沒有參數的函數,或者()
應該是什麼?
最好把它稱爲*單位類型,至少在這種情況下。 – Martijn 2010-05-24 11:49:23