Portability | portable |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Inferred |
These are general purpose combinators that provide utility for non-lens code
Documentation
(&) :: a -> (a -> b) -> bSource
Passes the result of the left side to the function on the right side (forward pipe operator).
This is the flipped version of ($
), which is more common in languages like F# as (|>
) where it is needed
for inference. Here it is supplied for notational convenience and given a precedence that allows it
to be nested inside uses of ($
).
>>>
a & f
f a
>>>
"hello" & length & succ
6
This combinator is commonly used when applying multiple Lens
operations in sequence.
>>>
("hello","world") & _1.element 0 .~ 'j' & _1.element 4 .~ 'y'
("jelly","world")
This reads somewhat similar to:
>>>
flip execState ("hello","world") $ do _1.element 0 .= 'j'; _1.element 4 .= 'y'
("jelly","world")