I've wanted this at times, too, due to using a lot of J a year or so ago. J has some weird parsing/semantics rules so that f g h essentially means liftM2 g f h. For example, avg =. +/ % # is the J equivalent of avg = liftM2 (/) sum length. Anyway, the closest you can get in Haskell is something like this, using the
infix expressions of Ken Shan and Dylan Thurston:
import Control.Monad
import Control.Monad.Instances
infixr 0 -:, :-
data Infix f y = f :- y
x -: f :- y = x `f` y
ov op = liftM2 op
ovL op f n = liftM2 op f (return n)
ovR op n f = liftM2 op (return n) f
hat f = liftM f
*Main> :t (*3) -:ov (+):- (/2)
(*3) -:ov (+):- (/2) :: forall a1. (Fractional a1) => a1 -> a1
*Main> ((*3) -:ov (+):- (/2)) 7
24.5
*Main> :t 3 -:ovR (+):- ((hat read) getContents)
3 -:ovR (+):- ((hat read) getContents) :: forall a. (Num a, Read a) => IO a
It works (?), but it's pretty ugly and hardly seems worth it, unfortunately.
-Brent