# [Haskell-cafe] Syntax proposal for "reverse apply"/"pipeline apply" (flip (\$))

Dan Burton danburton.email at gmail.com
Thu Apr 17 01:41:01 UTC 2014

```Interesting. I've never seen it proposed as right-associative before. Just
FYI, the implementation is as simple as this:

infixr 1 |^
(|^) :: a -> (a -> b) -> b
x |^ f = f x

Then you can write:

3 |^ 2 |^ (^) -- produces 2^3 = 8

It seems very odd to me. I don't know why you'd want to apply the arguments
backwards one by one. However, lens and diagrams both provide examples
where you want to start with a value and apply functions "forwards" one by
one, which is why their corresponding operators are left-associative.

-- Dan Burton

On Wed, Apr 16, 2014 at 4:49 PM, Alexey Muranov <alexey.muranov at gmail.com>wrote:

> On Thursday, April 17, 2014 1:38:48 AM UTC+2, Richard A. O'Keefe wrote:
>
>>
>> On 17/04/2014, at 10:25 AM, Alexey Muranov wrote:
>> > For whatever it is worth, i would like to propose for discussion a
>> syntax for "(flip (\$))" operation in Haskell.
>>
>> Oh, you mean like F#'s "|>" operator?
>>
>
>
>> If we were to copy an operator from F#, it would have been
>> nice to copy the F# name for it.  Sadly, Data.Sequence
>> already uses |> .  Hoogle doesn't find a (|^), so that might
>> work.
>>
>
> No, in fact i wanted to copy it from the exponential notation for function
> application.  In particular, it would need to be right-associative:
>
>     y |^ x |^ f == y |^ (x |^ f) == f x y
>
> Maybe a left-associative version can be defined too, by something like
> this:
>
>     x ^| g ^| f == (x ^| (g |^ f) = f (g x)
>
> _______________________________________________