Proposal: Add a wrapped applicative type to Data.Monoid

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Proposal: Add a wrapped applicative type to Data.Monoid

Daniel Cartwright
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

Andrew Martin
+1 from me. I've written this type at least a dozen times in various projects.

On Tue, Mar 27, 2018 at 10:22 AM, Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries




--
-Andrew Thaddeus Martin

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

David Feuer
In reply to this post by Daniel Cartwright
I proposed same thing some time ago. The main point of contention was the name. I hope you have better luck!

On Tue, Mar 27, 2018, 10:23 AM Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

Daniel Cartwright
I can definitely see "App" as being overloaded (Application).
Good names that I see are "Ap" and "Apply".

I think "Ap" is fine. 
On Tue, Mar 27, 2018, 10:28 AM David Feuer <[hidden email]> wrote:
I proposed same thing some time ago. The main point of contention was the name. I hope you have better luck!

On Tue, Mar 27, 2018, 10:23 AM Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

Daniel Cartwright
One thing that I would like to respectfully point out - is that the members' of this library mailing list end up derailing otherwise useful conversations over the choice of a name, which is frankly a silly bottleneck. I would much rather roll a die or flip a coin to choose a name, and just get on to implementing the proposed thing, provided it is the case that it is seen as generally useful.

On Tue, Mar 27, 2018 at 10:59 AM, Daniel Cartwright <[hidden email]> wrote:
I can definitely see "App" as being overloaded (Application).
Good names that I see are "Ap" and "Apply".

I think "Ap" is fine. 
On Tue, Mar 27, 2018, 10:28 AM David Feuer <[hidden email]> wrote:
I proposed same thing some time ago. The main point of contention was the name. I hope you have better luck!

On Tue, Mar 27, 2018, 10:23 AM Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

Edward Kmett-2
+1 to add it.

I don't care one way or the other about the name. =)

-Edward

On Tue, Mar 27, 2018 at 11:06 AM, Daniel Cartwright <[hidden email]> wrote:
One thing that I would like to respectfully point out - is that the members' of this library mailing list end up derailing otherwise useful conversations over the choice of a name, which is frankly a silly bottleneck. I would much rather roll a die or flip a coin to choose a name, and just get on to implementing the proposed thing, provided it is the case that it is seen as generally useful.

On Tue, Mar 27, 2018 at 10:59 AM, Daniel Cartwright <[hidden email]> wrote:
I can definitely see "App" as being overloaded (Application).
Good names that I see are "Ap" and "Apply".

I think "Ap" is fine. 
On Tue, Mar 27, 2018, 10:28 AM David Feuer <[hidden email]> wrote:
I proposed same thing some time ago. The main point of contention was the name. I hope you have better luck!

On Tue, Mar 27, 2018, 10:23 AM Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Proposal: Add a wrapped applicative type to Data.Monoid

Theodore Lief Gannon
So it's settled, we have an `Ed` type.

On Wed, Mar 28, 2018, 2:51 AM Edward Kmett <[hidden email]> wrote:
+1 to add it.

I don't care one way or the other about the name. =)

-Edward

On Tue, Mar 27, 2018 at 11:06 AM, Daniel Cartwright <[hidden email]> wrote:
One thing that I would like to respectfully point out - is that the members' of this library mailing list end up derailing otherwise useful conversations over the choice of a name, which is frankly a silly bottleneck. I would much rather roll a die or flip a coin to choose a name, and just get on to implementing the proposed thing, provided it is the case that it is seen as generally useful.

On Tue, Mar 27, 2018 at 10:59 AM, Daniel Cartwright <[hidden email]> wrote:
I can definitely see "App" as being overloaded (Application).
Good names that I see are "Ap" and "Apply".

I think "Ap" is fine. 
On Tue, Mar 27, 2018, 10:28 AM David Feuer <[hidden email]> wrote:
I proposed same thing some time ago. The main point of contention was the name. I hope you have better luck!

On Tue, Mar 27, 2018, 10:23 AM Daniel Cartwright <[hidden email]> wrote:
I see this as being generally (as in, to the users of Haskell as a whole) useful:

newtype Ap f a = Ap { getAp :: f a }
  deriving (Applicative, Eq, Foldable, Functor, Generic, Generic1
                ,Monad, Ord, Read, Show, Traversable)

Some hand-written instances:
instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where
  (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y

instance (Applicative f, Monoid a) => Monoid (Ap f a) where
  mempty = Ap $ pure mempty
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries