haskell - Every monad is monoid? -
since every monad
monoid
on sequencing operation. why doesn't monad
inherit monoid
in haskell?
it doesn't have monad
even, works every applicative
. yes, define:
class (functor f, monoid (f ())) => applicative f
but means have provide monoid
instance every time write applicative
instance. can quite annoying, since monoid
instance not used often.
a better solution create newtype wrapper around f ()
, , can provide monoid
instance applicative functors once , all. there's 1 readily available in the reducers package.
Comments
Post a Comment