Proposal: newtype for applicatives of monoids
 
            Sorry for the terrible title, but I think we should add something like the following to Data.Monoid (I already mentioned this in the discussion of a Monoid instance for ZipList). newtype Appl f m = Appl (f m) instance (Applicative f, Monoid m) => Monoid (Appl f m) where mempty = Appl $ pure mempty mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y It may be possible to use coercions to improve mplus; I haven't tried it. This type is the same as WrappedApplicative from semigroupoids, do it might be best just to give it that name.
 
            On 07/26/2015 11:34 PM, David Feuer wrote:
Sorry for the terrible title, but I think we should add something like the following to Data.Monoid (I already mentioned this in the discussion of a Monoid instance for ZipList).
newtype Appl f m = Appl (f m)
instance (Applicative f, Monoid m) => Monoid (Appl f m) where mempty = Appl $ pure mempty mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y
The method is called mappend, not mplus. Otherwise +1.
It may be possible to use coercions to improve mplus; I haven't tried it.
This type is the same as WrappedApplicative from semigroupoids, do it might be best just to give it that name.
The name Appl is the best fit with the recently-added Alt newtype, so I prefer it.
 
            On 2015-08-03, Mario Blažević wrote:
Date: Mon, 3 Aug 2015 10:22:56 From: Mario Blažević
To: libraries@haskell.org Subject: Re: Proposal: newtype for applicatives of monoids On 07/26/2015 11:34 PM, David Feuer wrote:
Sorry for the terrible title, but I think we should add something like the following to Data.Monoid (I already mentioned this in the discussion of a Monoid instance for ZipList).
newtype Appl f m = Appl (f m)
instance (Applicative f, Monoid m) => Monoid (Appl f m) where mempty = Appl $ pure mempty mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y
The method is called mappend, not mplus. Otherwise +1.
It may be possible to use coercions to improve mplus; I haven't tried it.
This type is the same as WrappedApplicative from semigroupoids, do it might be best just to give it that name.
+1, with mappend. (I just tripped over the Monad instance of the same thing. It's very nice to be able to use (<>) on something like Monad m => Control.Monad.Trans.Exception m () .) Cheers, David -- David Casperson, PhD, R.P., | David.Casperson@unbc.ca Associate Professor and Chair, | (250) 960-6672 Fax 960-5544 Computer Science | 3333 University Way University of Northern British Columbia | Prince George, BC V2N 4Z9 | CANADA
 
            Might as well capture all of 'em in one go.
+1 w/ aforementioned mappend/mplus fix.
On Sun, Jul 26, 2015 at 10:34 PM, David Feuer 
Sorry for the terrible title, but I think we should add something like the following to Data.Monoid (I already mentioned this in the discussion of a Monoid instance for ZipList).
newtype Appl f m = Appl (f m)
instance (Applicative f, Monoid m) => Monoid (Appl f m) where mempty = Appl $ pure mempty mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y
It may be possible to use coercions to improve mplus; I haven't tried it.
This type is the same as WrappedApplicative from semigroupoids, do it might be best just to give it that name.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Chris Allen Currently working on http://haskellbook.com
 
            To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley 
Christopher Allen
writes: Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1
John _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            On 08/03/2015 09:14 PM, Edward Kmett wrote:
To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
It *must* be App because apps are cool! ... I think? Regards,
 
            I don't want to take App because it's probably the most popular name for
representing function application in ASTs.
On Aug 3, 2015 3:14 PM, "Edward Kmett" 
To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
wrote: > Christopher Allen
writes: Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1
John _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            Ap seems a good name, and it's already used for that, so I'd support that
bike shed color.
On Aug 3, 2015 3:14 PM, "Edward Kmett" 
To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
wrote: > Christopher Allen
writes: Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1
John _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            +1 to Ap. On 04.08.2015 05:21, David Feuer wrote:
Ap seems a good name, and it's already used for that, so I'd support that bike shed color.
On Aug 3, 2015 3:14 PM, "Edward Kmett"
mailto:ekmett@gmail.com> wrote: To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
mailto:johnw@newartisans.com> wrote: >>>>> Christopher Allen
mailto:cma@bitemyapp.com> writes: > Might as well capture all of 'em in one go. > +1 w/ aforementioned mappend/mplus fix.
+1
John _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch. Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/
 
            There is also http://hackage.haskell.org/package/free-4.12.1/docs/Control-Applicative-Free... http://hackage.haskell.org/package/free-4.12.1/docs/Control-Applicative-Free..., which is totally different thing, yet related to Applicative. reducers Ap has getApp field name, which is probably copy&paste mistake: http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App... http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App... In that light I’d prefer - Appl with getAppl, - Ap unchanged in free package - App left free
On 05 Aug 2015, at 12:15, Andreas Abel
wrote: +1 to Ap.
On 04.08.2015 05:21, David Feuer wrote:
Ap seems a good name, and it's already used for that, so I'd support that bike shed color.
On Aug 3, 2015 3:14 PM, "Edward Kmett"
mailto:ekmett@gmail.com> wrote: To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
mailto:johnw@newartisans.com> wrote: >>>>> Christopher Allen
mailto:cma@bitemyapp.com> writes: > Might as well capture all of 'em in one go. > +1 w/ aforementioned mappend/mplus fix.
+1
John _______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org mailto:Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch.
Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden
andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/ _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            IIRC the accessor is still called getApp in reducers, which is slightly
inconsistent. Perhaps it'd be worth fixing on some future release that will
bring other incompatible changes.
Thanks
Petr
Dne po 3. 8. 2015 21:14 uživatel Edward Kmett 
Christopher Allen
writes: 
Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1 John _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            It was fixed in HEAD for a while. I've now shipped that fix as part of 3.11.
-Edward
On Wed, Aug 12, 2015 at 4:09 AM, Petr Pudlák 
IIRC the accessor is still called getApp in reducers, which is slightly inconsistent. Perhaps it'd be worth fixing on some future release that will bring other incompatible changes.
Thanks Petr
Dne po 3. 8. 2015 21:14 uživatel Edward Kmett
napsal: To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
wrote: Christopher Allen
writes: Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1
John
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
 
            Thanks!
Petr
Dne st 12. 8. 2015 17:54 uživatel Edward Kmett 
It was fixed in HEAD for a while. I've now shipped that fix as part of 3.11.
-Edward
On Wed, Aug 12, 2015 at 4:09 AM, Petr Pudlák
wrote: IIRC the accessor is still called getApp in reducers, which is slightly inconsistent. Perhaps it'd be worth fixing on some future release that will bring other incompatible changes.
Thanks Petr
Dne po 3. 8. 2015 21:14 uživatel Edward Kmett
napsal: To offer a couple more colors for the bikeshed:
In my old monoids package, this exists as App:
http://hackage.haskell.org/package/monoids-0.3.2/docs/Data-Monoid-Applicativ...
In the newer reducers package, it has been shortened to Ap:
http://hackage.haskell.org/package/reducers-3.10.3.2/docs/Data-Semigroup-App...
-Edward
On Mon, Aug 3, 2015 at 1:58 PM, John Wiegley
wrote: > Christopher Allen
writes: Might as well capture all of 'em in one go. +1 w/ aforementioned mappend/mplus fix.
+1
John
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
participants (10)
- 
                 Andreas Abel Andreas Abel
- 
                 Bardur Arantsson Bardur Arantsson
- 
                 Christopher Allen Christopher Allen
- 
                 David Casperson David Casperson
- 
                 David Feuer David Feuer
- 
                 Edward Kmett Edward Kmett
- 
                 John Wiegley John Wiegley
- 
                 Mario Blažević Mario Blažević
- 
                 Oleg Grenrus Oleg Grenrus
- 
                 Petr Pudlák Petr Pudlák
