Opened 7 years ago

Closed 5 years ago

#7434 closed feature request (duplicate)

Add (&) to Data.Function

Reported by: YitzGale Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 7.6.1
Keywords: Cc: pho@…, hvr, ekmett
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #9008 Differential Rev(s):
Wiki Page:


It is a common idiom to write a sequence of composed combinators in reverse order to the way they would be written with ($) or (.). That naturally expresses the idea of the combinators as operations being applied in the given order.

This comes up so often, and is commonly used so many times in a single expression, that Control.Arrow.>>> is far too wordy, and even a two-character operator is awkward.

Surprisingly, until recently the operator (&) was still not used in any of the popular libraries, and its name naturally expresses the idea we are looking for. This operator has now been defined in the lens package. We hereby propose to move it to its natural home for more general use, Data.Function.

As in the lens package, we define the operator as a flipped version of ($), but with slightly higher precedence for better interaction with ($), and with left associativity. This definition has already proven useful and convenient even in the presence of the large and varied corpus of combinators and operators in the lens package. (There it was formerly known as (%), but that clashed with the usual meaning of (%) from Data.Ratio.)

infixl 1 &
(&) :: a -> (a -> b) -> b
a & f = f a
{-# INLINE (&) #-}

Change History (4)

comment:1 Changed 7 years ago by PHO

Cc: pho@… added
Type: bugfeature request

comment:2 Changed 7 years ago by igloo

difficulty: Unknown
Resolution: wontfix
Status: newclosed

I'm closing this ticket while the discussion is going on on the libraries list. Please reopen, or open a new ticket, if a positive decision is reached (see for more details).

comment:3 Changed 5 years ago by hvr

Cc: hvr ekmett added
Resolution: wontfix
Status: closednew

comment:4 Changed 5 years ago by hvr

Resolution: duplicate
Status: newclosed

this was actually addressed via #9008

Note: See TracTickets for help on using tickets.