Proposal: Add "writer" Monad instance (,
) o to Control.Monad.Instances
conal at conal.net
Fri Sep 24 20:42:29 EDT 2010
FWIW, I think I used "o" for "output". I'd go with (->) i and (,) o .
On Fri, Sep 24, 2010 at 2:44 AM, Thomas Schilling
<nominolo at googlemail.com>wrote:
> I'd also prefer the variable to be called 'w' like for the writer
> Monad. But that's a bikeshed, so I don't mind either way.
> On 23 September 2010 16:58, Jake McArthur <jake.mcarthur at gmail.com> wrote:
> > This proposal  was originally submitted to Trac by Conal Elliott, but
> > was apparently abandoned and closed after some time. I've picked it back
> > and written out a patch. Here is the text of the proposal:
> >> I'd like to have a (,)-style writer instance alongside the (->)-based
> >> reader instance for Monad in Control.Monad.Instances.
> >> Here's the current reader:
> >> instance Monad ((->) r) where
> >> return = const
> >> f >>= k = \ r -> k (f r) r
> >> and my proposed writer:
> >> instance Monoid o => Monad ((,) o) where
> >> return = pure
> >> (o,a) >>= f = (o `mappend` o', a') where (o',a') = f a
> >> where the return definition relies on the Applicative instance of ((,)
> >> Written out explicitly,
> >> return a = (mempty,a)
> >> Control.Monad.Instances will also need two new imports:
> >> import Data.Monoid (Monoid(..))
> >> import Control.Applicative (pure)
> > - Jake
> >  http://hackage.haskell.org/trac/ghc/ticket/1951
> > _______________________________________________
> > Libraries mailing list
> > Libraries at haskell.org
> > http://www.haskell.org/mailman/listinfo/libraries
> Push the envelope. Watch it bend.
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries