[Haskell-cafe] Should `(flip (^^))` work?
wren ng thornton
wren at freegeek.org
Mon Sep 15 23:27:35 EDT 2008
Mauricio wrote:
> Hi,
>
> I tested the expression below
> and it doesn't work. Is there
> some way to achieve that (i.e.,
> turning an expression inside
> parenthesis into an operator)?
>
> 2 `(flip (^^))` (3%4)
Another solution if you don't like defining extra (-|) and (|-)
operators is:
> ($2) (flip (^^)) (3%4)
The right section of function application is type lifting. The general
form of this construction is:
> ($x) (f a b c...) y z...
Which is equal to (f a b c... x y z...). That is, the construction lets
you raise any argument out to before the function, thus making the
partially applied function into an infix between |x| and |y x...|.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list