Nathan van Doorn | 25 Jul 13:42 2013
Picon

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.
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Henning Thielemann | 25 Jul 13:46 2013
Picon

Re: Monad instance for Monoid e => (,) e


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.
Jake McArthur | 25 Jul 14:18 2013
Picon

Re: Monad instance for Monoid e => (,) e

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 <at> 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 <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Dan Burton | 25 Jul 16:46 2013
Picon

Re: Monad instance for Monoid e => (,) e

-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 <jake.mcarthur <at> gmail.com> wrote:

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 <at> 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 <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries


_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
David Luposchainsky | 25 Jul 14:05 2013

Re: Monad instance for Monoid e => (,) e

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
Edward Kmett | 25 Jul 19:14 2013
Picon

Re: Monad instance for Monoid e => (,) e

+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 <nvd1234 <at> gmail.com> 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.
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
John Wiegley | 25 Jul 21:09 2013

Re: Monad instance for Monoid e => (,) e

>>>>> Edward Kmett <ekmett <at> gmail.com> 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
Mario Blažević | 26 Jul 23:30 2013

Re: Monad instance for Monoid e => (,) e

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.

Gmane