[Proposal] Add instance Monoid a => Monoid (Const a b)
ekmett at gmail.com
Sun Sep 29 16:13:34 UTC 2013
A decent argument in favor is there really isn't another viable instance
for it. Being able to glue together folds with (<>) never occurred to me.
+1 from me
On Sun, Sep 29, 2013 at 12:01 PM, <haskell at nand.wakku.to> wrote:
> I think this a Monoid instance on Const would be useful. The motivation
> from ‘lens’, where folds come out as (a -> Const a a) -> s -> Const a s.
> instance, together with the Monoid a => Monoid (r -> a) instance, allows
> themselves to be an instance of Monoid, allowing for some really pretty
> Example of the instance body:
> > instance Monoid a => Monoid (Const a b) where
> > mempty = Const mempty
> > mappend (Const a) (Const b) = Const (mappend a b)
> Examples of it being used together with lens:
> >>> "Hello, world!" ^.. mconcat [ix 2, ix 7, ix 1]
> Discussion Period: 2 weeks
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries