[Haskell-cafe] Re: The Opposite of $

Alan Hawkins alanpika_au at yahoo.com
Tue Dec 4 03:47:48 EST 2007



|> is not defined in the prelude but can be defined as 

let (|>) = flip ($)

to make it the opposite of $ which means the syntax looks more like the
 Unix pipe '|' command

eg. 
filter  (\x-> x >3 && x < 7) $ [1..10] ++ [5]
[1..10] ++ [5] |> filter  (\x-> x >3 && x < 7)

res: [4,5,6]

note that with the |> the function applications are read as naturally
 left to right as apposed to the 
$ which reads left to right. a style more in line with the syntax f (x)





      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


More information about the Haskell-Cafe mailing list