Proposal: Add (&) to Data.Function
ekmett at gmail.com
Tue Nov 20 19:39:10 CET 2012
I'm a strong +1 for accepting this proposal as it stands.
I'm decidedly lukewarm / a weak -1 on switching it to (|>).
Another popular color of this bikeshed, (#) as is used in diagrams,
interacts very poorly with MagicHash and has a very high precedence that
ruins it for most dsl purposes.
We had it as (|>) in lens for a while and it didn't read well. It is often
used in long compositions and the extra character adds up when chained
-- >>> zipper ("hello","world") & down _1 & fromWithin traverse &
focus .~ 'J' & rightmost & focus .~ 'y' & rezip
isoRules = defaultRules
& handleSingletons .~ True
& singletonRequired .~ True
& singletonAndField .~ True
Both of those examples read much better with & than (|>).
We had switched to % from (|>) to be consistent with the other (+=) (*=)
operators where (%=) was being read as 'mod-equals' as a bit of a pun, and
could be seen as the application of the % operator to the target.
However this led to issues with a vocal minority who objected to it
changing the meaning of 4 % 3 on lambdabot when combined with NumInstances.
We converted to (&) because of its incredible terseness and general lack of
use across hackage. For DSL purposes, to me it is key that this operator be
as succinct as possible and (&) is remarkably underutilized in haskell
libraries today, due to the fact that (|) is taken by syntax, and our
C-inspired brains tend to pair them.
On Tue, Nov 20, 2012 at 1:27 PM, Michael Sloan <mgsloan at gmail.com> wrote:
> And the results of the IRC discussion on lens:
> I do think that this looks nicer, for whatever reason. While the mnemonic
> of "mod"ulus can suggest modify once you know that, (&) somewhat naturally
> suggests "and then" ... "and then". I still prefer (#) for overall
> consistency and history, but other than its conjunction connotations, (&)
> is mnemonically better.
> It'll be funny to mix diagrams and lens code - (&) is used for sticking
> coordinates together for points / vectors - while (#) would stand in for
> On Tue, Nov 20, 2012 at 10:17 AM, Michael Sloan <mgsloan at gmail.com> wrote:
>> (#) is also used by the diagrams library, mainly for using functions as
>> if they were "attributes".
>> In the context of lens, this is discussed a bit here:
>> On Tue, Nov 20, 2012 at 9:31 AM, Stephen Tetley <stephen.tetley at gmail.com
>> > wrote:
>>> "Haskell" called this operator (#) about 12 years ago - see Peter
>>> Thiemann's WASH and Eric Meijer and colleagues MS Agent scripting.
>>> I'd much prefer (#) if it didn't interfere with GHC's magic hash, I
>>> suspect the above authors were using Hugs...
>>> On 20 November 2012 17:19, Dan Burton <danburton.email at gmail.com> wrote:
>>> > Just to bring up some prior art, from what I've heard, F# calls this
>>> Libraries mailing list
>>> Libraries at haskell.org
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries