[Haskell-beginners] beginner's type error

Brent Yorgey byorgey at seas.upenn.edu
Fri Mar 27 09:11:14 EDT 2009

On Fri, Mar 27, 2009 at 06:01:15AM -0700, Michael Mossey wrote:
> Peter Verswyvelen wrote:
>> You can also get rid of the parentheses like this:
>> thing n = n + fromIntegral $ round $ sqrt n
> I'm having a hard time finding an explanation of the dollar signs. What do 
> they do? It looks like they break up the left-ro-right association of 
> function names to arguments.

($) is just function application.  It is defined as:

  f $ x = f x

This looks useless, of course, but it also has very low precedence, so
it is often used to avoid parentheses.  For example,

  (foo bar) (baz t)

can't be written without the parentheses, since that would be parsed
as ((foo bar) baz) t, but it can be written as

  foo bar $ baz t

> As a beginner, I love how Haskell is filled with so many good ideas, in 
> many areas. The basic concept of functional programming is good, but also 
> Haskell has beautiful syntax that's just pleasing to look at, and also has 
> many convenient features which may not quite qualify as "beautiful" or 
> "elegant" but are just convenient (still a worthy thing).

As a non-beginner, I love this too.  So I think you're on to something. =)


More information about the Beginners mailing list