Given a function for infix usage:
let f a b = (a+10, b)
f 4 5
=> (14,5)
4 `f` 5
=> (14,5)
The arguments can be flipped by defining a helper function:
let g = flip f
4 `g` 5
=> (15,4)
Is it possible to do this inline?
4 `flip f` 5
=> parse error on input `f'
4 `(flip f)` 5
=> parse error on input `('
My use case is Control.Arrow.first
. Instead of
(+10) `first` (7,8)
(17,8)
I would prefer a forward-application-style solution like
(7,8) `forwardFirst` (+10)
without needing to write
let forwardFirst = flip first
g
already? – Altarpiece(7,8) & _1 %~ (+10)
using lens. Of course, you can just use&
and write it as(7,8) & first (+10)
. Is this something similar to what you want? – Greenockite(&) = flip ($)
and using it as(7,8) & first (+10)
would be better than defining a flipped version of every function. – Greenockite