[Haskell-cafe] question regarding the $ apply operator

Brent Yorgey byorgey at seas.upenn.edu
Tue Jul 19 21:59:57 CEST 2011


On Mon, Jul 18, 2011 at 11:52:15PM -0700, Ting Lei wrote:
> 
> Thanks, Brandon,
> 
> That's a very clear explanation. I remembered that it's low, but forgot that it's this low.
> Maybe it's because of my mis-understanding that in C, infix operators have lower precedence.
> 
> Just curious, the following is not allowed in Haskell either for the same reason. 
> 
> applySkip i f ls = (take i) ls ++ $ f $ drop i ls
> 
> I read somewhere that people a couple of hundreds of years ago can manage to express things using ($)-like notation without any parenthesis at all.
> Is it possible to define an operator to achieve this which works
> with infix operators? If so, then ($) and parentheses are then
> really equivalent.

($) and parentheses are quite different.  Anyone who tells you they
are equivalent, although probably well-meaning, should be ignored.
Here is everything you need to know about ($):

  infixr 0 $
  f $ x = f x

Although working out all the implications of this definition may take
a bit of practice.

-Brent



More information about the Haskell-Cafe mailing list