[Haskell-cafe] Alternative lambda syntax (not entirely serious)

Tomasz Zielonka tomasz.zielonka at gmail.com
Mon Feb 21 16:13:10 EST 2005

On Fri, Feb 18, 2005 at 03:41:59PM -0800, Fritz Ruehr wrote:
> So, since a lambda abstraction denotes an anonymous function, the 
> underscore signifies anonymous things, and given that "->" of the 
> current syntax connotes a type than a value, I thought "why not this 
> syntax instead?": 
> 	(_ x = x)                -- the identity function 
> 	(_ (x,y) = x)            -- the fst function 
>     (_ f g x = f (g x))      -- composition 
> In other words, at a lexical level we simply write "_" in place of "\" 
> and "=" in place of "->". The use and placement of the "_" nicely 
> indicates that what we are denoting is both anonymous and a function, 
> and the use of the "=" makes it more parallel to the definition of a 
> named function. 

There would be an additional confusion if you couldn't replace _ with
a named variable. If you could, it would be interesting, as it would
allow to succintly define anonymous recursive functions (without let,
where or fix). Unfortunately, it looks like parsing nightmare, both for
humans and compilers.

Best regards

More information about the Haskell-Cafe mailing list