
30 May
2011
30 May
'11
10:53 a.m.
On Mon, May 30, 2011 at 9:01 AM, John Ky
instance Monoid (Stream a) where mempty = Chunks mempty mappend (Chunks xs) (Chunks ys) = Chunks (xs ++ ys) mappend _ _ = EOF
I guess, it shows my lack of experience in Haskell, but my question is, why is writing the code this way preferred over say writing it like this:
I don't care for the inconsistency in this example, using both mempty and (++). Your version is at least consistent, but I'd actually prefer to use mappend instead of (++) here, because it makes it clear that this isn't actually defining a "new" Monoid instance, just translating an existing instance for the constructor parameter to work for the surrounding data type. - C.