Proposal: Add (<$>) to Prelude as part of the AMP in GHC 7.10-RC3

Alp Mestanogullari alpmestan at gmail.com
Fri Feb 27 10:46:55 UTC 2015


Definitely +1 on <$>. +0.5 on <$, I suspect this one being in the Prelude
or not isn't as big a deal as for <$>.

On Fri, Feb 27, 2015 at 9:58 AM, S. Doaitse Swierstra <doaitse at swierstra.net
> wrote:

> They definitely should be in both, since the default implementations of
> <$> and <$
>
> f <$> x = pure f <*> x
> f <$   x  = const f <*> x
>
> may be less efficient than a special implementation having more knowledge
> about applicative.
>
>  Doaitse
>
> PS: for that reason they are for almost 20 years now member of the class
> IsParser in
> http://hackage.haskell.org/package/uulib-0.9.16/docs/UU-Parsing-Interface.html ,
> which inspired the introduction of Applicative and Alternative in the first
> place.
>
>
>
>
>
>
> On 27 Feb 2015, at 5:45 , Edward Kmett <ekmett at gmail.com> wrote:
>
> On Thu, Feb 26, 2015 at 6:37 PM, Greg Fitzgerald <garious at gmail.com>
> wrote:
>
>> Those operators are for Power Users - why put them in the Prelude?
>
>
> .. because without them that whole Applicative thing that we're bringing
> in as a superclass of Monad with the AMP is cut off at the knees.
>
> Applicative sugar is typically used like
>
> both f (x,y) = (,) <$> x <*> y
>
> or
>
> traverse f (x:xs) = (:) <$> f x <*> traverse f xs
> traverse f [] = pure []
>
> Without (<$>), (<*>) from Applicative is quite difficult to use.
>
> both f (x,y) = pure (,) <*> x <*> y
>
> is much less efficient and
>
> both f (x,y) = fmap (,) x <*> y
>
> is painfully far from idiomatic.
>
> -Edward
>
> -Greg
>>
>>
>> > Dne út 24. 2. 2015 16:39 uživatel Edward Kmett <ekmett at gmail.com>
>> napsal:
>> >>
>> >> We have a couple of weeks until the third release candidate for GHC
>> 7.10
>> >> goes out the door.
>> >>
>> >> Along the way with the last couple of release candidates folks have
>> found
>> >> some problems with the way we implemented the AMP. [1][2]
>> >>
>> >> Most notably, we failed to include (<$>) in the Prelude, so the
>> standard
>> >> idiom of
>> >>
>> >> foo <$> bar <*> baz <*> quux
>> >>
>> >> doesn't work out of the box!
>> >>
>> >> I'd like to include (<$>) in the Prelude in RC3.
>> >>
>> >> I'd also like to invite discussion about whether folks believe we
>> should
>> >> include (<$) out of the box.
>> >>
>> >> (<$) has been a member of Functor for a long time, which is only
>> visible
>> >> if you import it from Data.Functor or bring in Control.Applicative.
>> There is
>> >> an idiom that you use (<*) and (<$) to point to the parts of the
>> structure
>> >> that you want to keep the answers from when building longer such
>> Applicative
>> >> chains.
>> >>
>> >> Discussion Period: 2 weeks
>> >>
>> >> Thank you,
>> >> -Edward Kmett
>> >>
>> >> [1]
>> >>
>> http://www.reddit.com/r/haskell/comments/2wzixa/shouldnt_be_in_prelude/
>> >> [2] https://plus.google.com/115504368969270249241/posts/URzeDWd7qMp
>> >> _______________________________________________
>> >> Libraries mailing list
>> >> Libraries at haskell.org
>> >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>> >
>> >
>> > _______________________________________________
>> > Libraries mailing list
>> > Libraries at haskell.org
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>> >
>>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>


-- 
Alp Mestanogullari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150227/0b06ab14/attachment.html>


More information about the Libraries mailing list