3 `\x y -> x + y` 4 `\x y -> x + y` 5
Rijk J. C. van Haaften
Rijk J. C. van Haaften" <rjchaaft@cs.uu.nl
Thu, 22 Aug 2002 16:49:58 +0100
Hello everybody,
Every now and then I hear people complain
that writing expressions like in the subject line
is impossible, though desirable in some cases.
Today, I ran into a situation where I really needed
that feature, because I were working with a code
generator (UU_AG) that allows just infix functions
at some point.
So I thought about it for a minute and then I solved
it this way. Maybe it's useful to others as well, so
I post it here.
module InfixFunction where
-- This is a flipped $
infixl 0 $-
($-) :: a -> (a -> b) -> b
($-) x f = f x
example1 :: Int
example1 =
-- 3 `\x y -> x + y` 4
3 $- (\y x -> x + y) 4
example2 :: Int
example2 =
-- 1 `\x y -> x + y` 2 `\x y -> x` 3
1 $- (\y x -> x + y) 2 $- (\y x -> x + y) 3
Rijk-Jan van Haaften