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

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to