2
として、私は次のデータ型のためのFunctorのインスタンスを作成しようとしていません:タイプは、多型として提案
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 α γ)
私はいくつかの追加しようとしましたレットバインディングを一般化するためにタイプアノテーションを使用しましたが、これは機能しませんでした。
助け行くために型注釈を追加します。 –