:: a -> (a -> b) -> b -package:lens-family-core -package:hmatrix -package:ghc-lib-parser -package:diagrams-lib -package:incipit-base

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $. This is a version of flip id, where id is specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is (a -> b) -> a -> b. flipping this yields a -> (a -> b) -> b which is the type signature of &

Examples

>>> 5 & (+1) & show
"6"
>>> sqrt $ [1 / n^2 | n <- [1..1000]] & sum & (*6)
3.1406380562059946
& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.
>>> 5 & (+1) & show
"6"
Helper to make code using records of clients more readable. Can be mixed with (/:) for supplying arguments. Example:
type Api = NamedRoutes RootApi

data RootApi mode = RootApi
{ subApi :: mode :- NamedRoutes SubApi
, …
} deriving Generic

data SubApi mode = SubApi
{ endpoint :: mode :- Get '[JSON] Person
, …
} deriving Generic

api :: Proxy API
api = Proxy

rootClient :: RootApi (AsClientT ClientM)
rootClient = client api

endpointClient :: ClientM Person
endpointClient = client // subApi // endpoint
Flipped version of ($).
& is a reverse application operator
Reverse function application which binds tighter than <$> and <*>. Useful for refining grammar specification.
<*> monoidalFieldAla "extensions"           (alaList' FSep MQuoted)       oldExtensions
^^^ deprecatedSince [1,12] "Please use 'default-extensions' or 'other-extensions' fields."
Field access, inspired by the lens library. This is merely reverse application, but allows us to write things like (1, 2)^._1 which is likely to be familiar to most Haskell programmers out there. Note that this is precisely equivalent to _1 (1, 2), but perhaps it reads a little nicer.
Left-associative apply operator. Read as "apply forward" or "pipe into". Use this to create long chains of computation that suggest which direction things move in.
>>> 3 |> succ |> recip |> negate
-0.25
Or use it anywhere you would use (&).
\ x -> (x |> f) == f x
\ x -> (x |> f |> g) == g (f x)
Function application. This function usually isn't necessary, but it can be more readable than some alternatives when used with higher-order functions like map.
>>> map (apply 2) [succ, recip, negate]
[3.0,0.5,-2.0]
In general you should prefer using an explicit lambda or operator section.
>>> map (\ f -> 2 |> f) [succ, recip, negate]
[3.0,0.5,-2.0]

>>> map (2 |>) [succ, recip, negate]
[3.0,0.5,-2.0]

>>> map (<| 2) [succ, recip, negate]
[3.0,0.5,-2.0]
\ x -> apply x f == f x
Left-associative apply' operator. Read as "strict apply forward" or "strict pipe into". Use this to create long chains of computation that suggest which direction things move in.
>>> 3 !> succ !> recip !> negate
-0.25
The difference between this and (|>) is that this evaluates its argument before passing it to the function.
>>> undefined |> const True
True

>>> undefined !> const True
*** Exception: Prelude.undefined
...
\ x -> (x !> f) == seq x (f x)
\ x -> (x !> f !> g) == let y = seq x (f x) in seq y (g y)
Strict function application. This function usually isn't necessary, but it can be more readable than some alternatives when used with higher-order functions like map.
>>> map (apply' 2) [succ, recip, negate]
[3.0,0.5,-2.0]
The different between this and apply is that this evaluates its argument before passing it to the function.
>>> apply undefined (const True)
True

>>> apply' undefined (const True)
*** Exception: Prelude.undefined
...
In general you should prefer using an explicit lambda or operator section.
>>> map (\ f -> 2 !> f) [succ, recip, negate]
[3.0,0.5,-2.0]

>>> map (2 !>) [succ, recip, negate]
[3.0,0.5,-2.0]

>>> map (<! 2) [succ, recip, negate]
[3.0,0.5,-2.0]
\ x -> apply' x f == seq x (f x)
Reverse function application. Allows convenient notation for setting properties. Example usage.
mkElement "div"
# set style     [("color","#CCAABB")]
# set draggable True
# set children  otherElements
The #-operator is the Haskell analog to the .-operator in JavaScript. Example:
grd # addColorStop(0, "#8ED6FF");
This can be seen as equivalent of grd.addColorStop(0, "#8ED6FF").
Operator for postfix notation (same as Data.Function.(&))
>>> 255 .@hex
"0x0000_0000_0000_00ff"

>>> 0xf1 .@bin
"0b1111_0001"

>>> 2^12 .@dec
"4096"

>>> 4 * giga .@pos1
[32]
0x0 .@color (bits 31 24)
0b0000_0000_0000_0000_0000_0000_0000_0000_1111_1111_0000_0000_0000_0000_0000_0000
^^^^ ^^^^
Hang on function application, a.k.a. non-operator version of &.
onApp = (&)
A flipped version of ($).
An operator that allows you to write C-style ternary conditionals of the form:
p ? t ?? f
Note that parentheses are required in order to chain sequences of conditionals together. This is probably a good thing.
($) is the function application operator. Applying ($) to a function f and an argument x gives the same result as applying f to x directly. The definition is akin to this:
($) :: (a -> b) -> a -> b
($) f x = f x
This is id specialized from a -> a to (a -> b) -> (a -> b) which by the associativity of (->) is the same as (a -> b) -> a -> b. On the face of it, this may appear pointless! But it's actually one of the most useful and important operators in Haskell. The order of operations is very different between ($) and normal function application. Normal function application has precedence 10 - higher than any operator - and associates to the left. So these two definitions are equivalent:
expr = min 5 1 + 5
expr = ((min 5) 1) + 5
($) has precedence 0 (the lowest) and associates to the right, so these are equivalent:
expr = min 5 $ 1 + 5
expr = (min 5) (1 + 5)

Examples

A common use cases of ($) is to avoid parentheses in complex expressions. For example, instead of using nested parentheses in the following Haskell function:
-- | Sum numbers in a string: strSum "100  5 -7" == 98
strSum :: String -> Int
strSum s = sum (mapMaybe readMaybe (words s))
we can deploy the function application operator:
-- | Sum numbers in a string: strSum "100  5 -7" == 98
strSum :: String -> Int
strSum s = sum $ mapMaybe readMaybe $ words s
($) is also used as a section (a partially applied operator), in order to indicate that we wish to apply some yet-unspecified function to a given value. For example, to apply the argument 5 to a list of functions:
applyFive :: [Int]
applyFive = map ($ 5) [(+1), (2^)]
>>> [6, 32]

Technical Remark (Representation Polymorphism)

($) is fully representation-polymorphic. This allows it to also be used with arguments of unlifted and even unboxed kinds, such as unboxed integers:
fastMod :: Int -> Int -> Int
fastMod (I# x) (I# m) = I# $ remInt# x m
Strict (call-by-value) application operator. It takes a function and an argument, evaluates the argument to weak head normal form (WHNF), then calls the function with that value.
The oneShot function can be used to give a hint to the compiler that its argument will be called at most once, which may (or may not) enable certain optimizations. It can be useful to improve the performance of code in continuation passing style. If oneShot is used wrongly, then it may be that computations whose result that would otherwise be shared are re-evaluated every time they are used. Otherwise, the use of oneShot is safe. oneShot is representation-polymorphic: the type variables may refer to lifted or unlifted types.
Delay inlining a function until late in the game (simplifier phase 0).
Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted; for example:
f $ g $ h x  =  f (g (h x))
It is also useful in higher-order situations, such as map ($ 0) xs, or zipWith ($) fs xs. Note that ($) is levity-polymorphic in its result type, so that foo $ True where foo :: Bool -> Int# is well-typed.