Reputation: 34099
I am trying to learn haskell and reading the haskellbook.
In the book, the author mentioned larger type as follow:
instance Monoid b => Monoid (a -> b)
instance (Monoid a, Monoid b) => Monoid (a, b)
instance (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)
What these Monoids have in common is that they are giving you a new Monoid for a larger type by reusing the Monoid instances of types that represent components of the larger type.
What does he mean with larger datatype?
Upvotes: 1
Views: 88
Reputation: 833
I think the author means this: a tuple may contain some Monoid
instance a
, b
, and c
. However, we can view the Monoid
instances in those tuples collectively, and thus define a new Monoid
of type (a, b, c)
. Thus, from 3 smaller Monoid
instances grouped together in a tuple give rise to a "larger" Monoid
instance over (a, b, c)
.
Upvotes: 5