[Haskell-cafe] What's the advantage of writing Haskell this way?

Malcolm Wallace malcolm.wallace at me.com
Tue May 31 07:54:16 CEST 2011


instance (Monad m, MonadPlus m) => Monoid (Stream m a) where
> 	mempty = Chunks mempty
> 	mappend (Chunks xs) (Chunks ys) = Chunks (xs `mappend` ys)
> 	mappend _ _ = EOF
> 
> 
> Iteratee.hs:28:25:
>     No instance for (Monoid (m a))
>       arising from a use of `mempty'
> 

There is a clue in the first part of the error message.  Add the required instance as part of the predicate:

instance (Monad m, MonadPlus m, Monoid (m a)) => Monoid (Stream m a) where ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110531/510ce55e/attachment.htm>


More information about the Haskell-Cafe mailing list