Flipped function application

Edward Kmett ekmett
Thu Oct 10 18:50:18 UTC 2013


We've found with lens in practice it is actually quite useful to have (&)
bind just a touch tighter than ($), but yes, we do tend to discourage users
from mashing them together:

makeMyLenses = makeLensesWith $
  defaultRules & ... & ... & ...

-Edward



On Thu, Oct 10, 2013 at 2:18 PM, David Menendez <dave at zednenem.com> wrote:

> On Thu, Oct 10, 2013 at 1:08 PM, Wvv <vitea3v at rambler.ru> wrote:
>
>> We want to combine all of them, like
>>
>> xs # map $ (+ 3) . snd
>>
>> And xs $$ map $ (+ 3) . snd  - don't look nice.
>>
>
> That's actually a pretty good example of why this is a bad idea. You can't
> know which argument is being applied first unless you know the precedence
> levels.
>
> In fact, according to the fixity you initially proposed, that translates to
>
> (xs # map) $ (+3) . snd
>
> The corrected version, xs # (map $ (+3) . snd), isn't much better. Even
> with the parentheses, it's needlessly confusing. ($) and (#) should never
> appear in the same expression, or at least they shouldn't apply arguments
> to the same function. It would be like using (.) and (>>>) together.
>
> --
> Dave Menendez <dave at zednenem.com>
> <http://www.eyrie.org/~zednenem/>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20131010/ebae0a08/attachment.html>




More information about the Libraries mailing list