data MyData a b = MyData a b b
Why is the first instantiation good and the second not ?
instance Foldable (MyData a) where
foldMap f (MyData x y z) = f y <> f z
instance Foldable (MyData a) where
foldMap f (MyData x y z) = f z
f
maps both y
and z
into a monoid, so f z
and f y <> f z
are instances of that monoid. So, why is the second not ok ?