2
我试图做一个仿函数实例下列数据类型:类型不是多态的建议
data Event t a = Event { runEvent :: t -> ([a], Event t a) }
instance Functor (Event t) where
fmap :: (a -> b) -> Event t a -> Event t b
fmap f e = Event go
where
go t = (fmap f x, e')
where
(x, e') = Event.runEvent e t
但是编译失败,出现以下错误:
E FRP.fr:11: type `γ` is not as polymorphic as suggested in
the annotation where just `β` is announced.
E FRP.fr:11: type error in expression go
type is : ([γ],Event α β)
expected: ([γ],Event α γ)
我尝试添加一些键入注释来概括let绑定,但这不起作用。
添加类型注释去帮助。 –