Monad instance for Monoid e => (,) e

This is a relatively simple instance, so I was surprised that I couldn't find it in base. My proposal is to add the instance to Control.Monad.Instances, undeprecating the module.

On Thu, 25 Jul 2013, Nathan van Doorn wrote:
This is a relatively simple instance, so I was surprised that I couldn't find it in base. My proposal is to add the instance to Control.Monad.Instances, undeprecating the module.
Wasn't it already added? Nonetheless, I strongly suggest to use Control.Monad.Trans.Writer instead. To me, using a pair as a monad looks like an error not like a feature.

There was a proposal to add it, but it went stale. I favor adding it.
On Jul 25, 2013 7:47 AM, "Henning Thielemann"
On Thu, 25 Jul 2013, Nathan van Doorn wrote:
This is a relatively simple instance, so I was surprised that I couldn't
find it in base. My proposal is to add the instance to Control.Monad.Instances, undeprecating the module.
Wasn't it already added? Nonetheless, I strongly suggest to use Control.Monad.Trans.Writer instead. To me, using a pair as a monad looks like an error not like a feature.
______________________________**_________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/**mailman/listinfo/librarieshttp://www.haskell.org/mailman/listinfo/libraries

-0.1
It's... obscure to make the instance this way.
(a,b) >>= (,) a' -- wat
Not very harmful, but obscure. (Cute trick for golfing?) I would suggest
using the writer monad instead, which is the same thing, but newtyped for
sanity (and tuple flipped).
-- Dan Burton
On Thu, Jul 25, 2013 at 5:18 AM, Jake McArthur
There was a proposal to add it, but it went stale. I favor adding it. On Jul 25, 2013 7:47 AM, "Henning Thielemann" < lemming@henning-thielemann.de> wrote:
On Thu, 25 Jul 2013, Nathan van Doorn wrote:
This is a relatively simple instance, so I was surprised that I couldn't
find it in base. My proposal is to add the instance to Control.Monad.Instances, undeprecating the module.
Wasn't it already added? Nonetheless, I strongly suggest to use Control.Monad.Trans.Writer instead. To me, using a pair as a monad looks like an error not like a feature.
______________________________**_________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/**mailman/listinfo/librarieshttp://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On 2013-07-25 13:42, Nathan van Doorn wrote:
This is a relatively simple instance, so I was surprised that I couldn't find it in base. My proposal is to add the instance to Control.Monad.Instances, undeprecating the module.
The instance may be right, but I'm not sure whether it's right to make use of it. In case it is added, maybe Data.Tuple would be a good place to put it. David

+1 to the spirit of is proposal if not the planned execution
I continue to be strongly in favor of adding this instance as it is a fundamental variant of the Writer Monad, and is analogous to the Monad/MonadReader instances for (->) e.
The tricky part is how to structure base so that it happens, as the context mentions Monoid, but Monoid which appears in the context isn't currently in the Prelude, yet Monad and the (,) data type are known to the Prelude. Orphaning it is less than ideal.
However, that seems to be resolving itself. Given the direction of the AMP and Foldable/Traversable changes that we're working towards for 7.10 and the attendant need to bring Monoid into the Prelude, that may be a good time to fix up this missing instance and expose it properly.
This way we don't have to bring that module full of orphans back to life.
-Edward
On Jul 25, 2013, at 7:42 AM, Nathan van Doorn
This is a relatively simple instance, so I was surprised that I couldn't find it in base.
My proposal is to add the instance to Control.Monad.Instances, undeprecating the module. _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Edward Kmett
writes:
I continue to be strongly in favor of adding this instance as it is a fundamental variant of the Writer Monad, and is analogous to the Monad/ MonadReader instances for (->) e.
+1, also for this reason. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net

On 13-07-25 01:14 PM, Edward Kmett wrote:
+1 to the spirit of is proposal if not the planned execution
I continue to be strongly in favor of adding this instance as it is a fundamental variant of the Writer Monad, and is analogous to the Monad/MonadReader instances for (->) e.
The tricky part is how to structure base so that it happens, as the context mentions Monoid, but Monoid which appears in the context isn't currently in the Prelude, yet Monad and the (,) data type are known to the Prelude. Orphaning it is less than ideal.
However, that seems to be resolving itself. Given the direction of the AMP and Foldable/Traversable changes that we're working towards for 7.10 and the attendant need to bring Monoid into the Prelude, that may be a good time to fix up this missing instance and expose it properly.
This way we don't have to bring that module full of orphans back to life.
I'm late to the party, but +1.
participants (8)
-
Dan Burton
-
David Luposchainsky
-
Edward Kmett
-
Henning Thielemann
-
Jake McArthur
-
John Wiegley
-
Mario Blažević
-
Nathan van Doorn