Edward Kmett | 5 Aug 21:06 2013
Picon

Improving void

Right now the definition of Control.Monad.void is: void :: Functor f => f a -> f () void = fmap (const ()) I propose we replace it withvoid :: Functor f => f a -> f () void = (() <$)This expands out to the former definition by the default definition of (<$) and Data.Functor.Functor exports (<$) explicitly to make it possible to optimize this sort of thing. It seems a shame not to use it. Discussion Period: 2 weeks
_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
David Luposchainsky | 5 Aug 23:35 2013

Re: Improving void

On 2013-08-05 21:06, Edward Kmett wrote:
> Right now the definition of Control.Monad.void is:
> 
> void :: Functor f => f a -> f ()
> void = fmap (const ())
> 
> I propose we replace it with
> 
> void :: Functor f => f a -> f ()
> void = (() <$)

I don't see any argument against that. I'd say this is a no-brainer
nobody would mind being done without doing the mailing list thing.

David
Edward Kmett | 6 Aug 01:57 2013
Picon

Re: Improving void

Sure, but I figured there was no pain in going through the ceremony of it all. ;)


-Edward

On Mon, Aug 5, 2013 at 5:35 PM, David Luposchainsky <dluposchainsky <at> googlemail.com> wrote:
On 2013-08-05 21:06, Edward Kmett wrote:
> Right now the definition of Control.Monad.void is:
>
> void :: Functor f => f a -> f ()
> void = fmap (const ())
>
> I propose we replace it with
>
> void :: Functor f => f a -> f ()
> void = (() <$)

I don't see any argument against that. I'd say this is a no-brainer
nobody would mind being done without doing the mailing list thing.

David

_______________________________________________
Libraries mailing list
Libraries <at> haskell.org
http://www.haskell.org/mailman/listinfo/libraries
Malcolm Wallace | 6 Aug 08:32 2013

Re: Improving void

Can you explain why you think it is an improvement?
To me, it looks like line noise.

 Regards,
    Malcolm

On 5/08/2013, at 20:06, Edward Kmett <ekmett <at> gmail.com> wrote:

Right now the definition of Control.Monad.void is: void :: Functor f => f a -> f () void = fmap (const ()) I propose we replace it withvoid :: Functor f => f a -> f () void = (() <$)This expands out to the former definition by the default definition of (<$) and Data.Functor.Functor exports (<$) explicitly to make it possible to optimize this sort of thing. It seems a shame not to use it. Discussion Period: 2 weeks
_______________________________________________
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
Ivan Lazar Miljenovic | 6 Aug 09:04 2013
Picon

Re: Improving void

On 6 August 2013 16:32, Malcolm Wallace <malcolm.wallace <at> me.com> wrote:
> Can you explain why you think it is an improvement?
> To me, it looks like line noise.

I think it's becaue (<$) is a method of the Functor class, with a
default definition of "fmap . const"; however, it's possible that some
instances might have a custom definition which would be more efficient
than using "fmap (const ())".

>
>  Regards,
>     Malcolm
>
> On 5/08/2013, at 20:06, Edward Kmett <ekmett <at> gmail.com> wrote:
>
> Right now the definition of Control.Monad.void is:
>
> void :: Functor f => f a -> f ()
>
> void = fmap (const ())
>
> I propose we replace it with
>
> void :: Functor f => f a -> f ()
>
> void = (() <$)
>
> This expands out to the former definition by the default definition of (<$)
> and Data.Functor.Functor exports (<$) explicitly to make it possible to
> optimize this sort of thing. It seems a shame not to use it.
>
> Discussion Period: 2 weeks
>
> _______________________________________________
>
> 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
>

--

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic <at> gmail.com
http://IvanMiljenovic.wordpress.com
Erik Hesselink | 6 Aug 09:04 2013
Picon

Re: Improving void

The (<$) operator is part of the Functor type class. The default
implementation is `fmap . const`, but instances can provide a more
optimized implementation. Since void is `fmap (const ())`, this
proposal will make it more efficient for some Functors.

Erik

On Tue, Aug 6, 2013 at 8:32 AM, Malcolm Wallace <malcolm.wallace <at> me.com> wrote:
> Can you explain why you think it is an improvement?
> To me, it looks like line noise.
>
>  Regards,
>     Malcolm
>
> On 5/08/2013, at 20:06, Edward Kmett <ekmett <at> gmail.com> wrote:
>
> Right now the definition of Control.Monad.void is:
>
> void :: Functor f => f a -> f ()
>
> void = fmap (const ())
>
> I propose we replace it with
>
> void :: Functor f => f a -> f ()
>
> void = (() <$)
>
> This expands out to the former definition by the default definition of (<$)
> and Data.Functor.Functor exports (<$) explicitly to make it possible to
> optimize this sort of thing. It seems a shame not to use it.
>
> Discussion Period: 2 weeks
>
> _______________________________________________
>
> 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
>
Edward Kmett | 6 Aug 14:34 2013
Picon

Re: Improving void

Because there are many Functors for which (<$) provides better sharing and/or performance, and it has zero impact on anyone who has never heard of (<$).

Sent from my iPad

On Aug 6, 2013, at 2:32 AM, Malcolm Wallace <malcolm.wallace <at> me.com> wrote:

Can you explain why you think it is an improvement?
To me, it looks like line noise.

 Regards,
    Malcolm

On 5/08/2013, at 20:06, Edward Kmett <ekmett <at> gmail.com> wrote:

Right now the definition of Control.Monad.void is: void :: Functor f => f a -> f () void = fmap (const ()) I propose we replace it withvoid :: Functor f => f a -> f () void = (() <$)This expands out to the former definition by the default definition of (<$) and Data.Functor.Functor exports (<$) explicitly to make it possible to optimize this sort of thing. It seems a shame not to use it. Discussion Period: 2 weeks
_______________________________________________
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
Herbert Valerio Riedel | 6 Aug 09:57 2013
Picon

Re: Improving void

On 2013-08-05 at 21:06:07 +0200, Edward Kmett wrote:

[...]

> I propose we replace it with
>
> void :: Functor f => f a -> f ()
> void = (() <$)

+1
John Wiegley | 6 Aug 20:42 2013

Re: Improving void

>>>>> Edward Kmett <ekmett <at> gmail.com> writes:

> I propose we replace it with

> void :: Functor f => f a -> f ()
> void = (() <$)

+1

Edward recently convinced me that 'void' has some hidden costs (over, say, the
idiom of "_ <-"), so I'm in favor of anything that may ameliorate those costs.

--

-- 
John Wiegley
FP Complete                         Haskell tools, training and consulting
http://fpcomplete.com               johnw on #haskell/irc.freenode.net
wren ng thornton | 7 Aug 05:18 2013

Re: Improving void

On 8/5/13 3:06 PM, Edward Kmett wrote:
> Right now the definition of Control.Monad.void is:
>
> void :: Functor f => f a -> f ()
>
> void = fmap (const ())
>
> I propose we replace it with
>
> void :: Functor f => f a -> f ()
>
> void = (() <$)
>
> This expands out to the former definition by the default definition of
> (<$) and Data.Functor.Functor exports (<$) explicitly to make it
> possible to optimize this sort of thing. It seems a shame not to use
> it.

+1. That was the entire point of (<$) being added to the class afterall.

--

-- 
Live well,
~wren
Dan Burton | 7 Aug 21:57 2013
Picon

Re: Improving void

+1

(This should be an hlint warning if it is not already.)

-- Dan Burton

On Aug 6, 2013 8:19 PM, "wren ng thornton" <wren <at> freegeek.org> wrote:
On 8/5/13 3:06 PM, Edward Kmett wrote:
> Right now the definition of Control.Monad.void is:
>
> void :: Functor f => f a -> f ()
>
> void = fmap (const ())
>
> I propose we replace it with
>
> void :: Functor f => f a -> f ()
>
> void = (() <$)
>
> This expands out to the former definition by the default definition of
> (<$) and Data.Functor.Functor exports (<$) explicitly to make it
> possible to optimize this sort of thing. It seems a shame not to use
> it.

+1. That was the entire point of (<$) being added to the class afterall.

--
Live well,
~wren


_______________________________________________
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

Gmane