Skip to content

Instantly share code, notes, and snippets.

@edwardw
Created July 3, 2011 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edwardw/1062084 to your computer and use it in GitHub Desktop.
Save edwardw/1062084 to your computer and use it in GitHub Desktop.
Haskell operator section

In this wonderful tutorial "Write Yourself a Scheme in 48 Hours", this line puzzles me for a while:

apply :: String -> [LispVal] -> LispVal
apply func args = maybe (Bool False) ($ args) $ lookup func primitives

What does ($ args) really mean? Turns out it is called operator section, a special syntax which LYSH fails to mention. This thread did a great job on explaining it:

http://www.haskell.org/pipermail/beginners/2009-January/000776.html

And the definition of it is here:

http://www.haskell.org/onlinereport/exps.html#sections

and here:

http://www.haskell.org/haskellwiki/Section_of_an_infix_operator

Also be careful that - operator cannot do a right section, use Prelude subtract instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment