1
このデータ型のFoldableインスタンスはどのように見えますか?一見単純なFoldableインスタンスの定義
data X t = X t [X t]
私はこの試みた:
instance Foldable X where
foldMap f (X x xs) = f x `mappend` foldMap f xs
をしかし、このエラーを得た:
Occurs check: cannot construct the infinite type: a = X a
When generalising the type(s) for `foldMap'
In the instance declaration for `Foldable X'