I just tried to use the generic form with (Maybe a) and 'mconcat' prevented this from working, so that needs to be considered too.
On Mon, May 30, 2011 at 10:53 PM, Casey McCann <[email protected]> wrote: > On Mon, May 30, 2011 at 9:01 AM, John Ky <[email protected]> wrote: >> 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. > > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
