[Haskell-cafe] Syntax for lambda case proposal could be "\of"

Brian Hulley brianh at metamilk.com
Wed Aug 15 14:40:07 EDT 2007

Stefan O'Rear wrote:
> On Wed, Aug 15, 2007 at 06:58:40PM +0100, Duncan Coutts wrote:
>> On Wed, 2007-08-15 at 10:50 -0700, Stefan O'Rear wrote:
>>> OTOH, your proposal provides (IMO) much more natural syntax for
>>> multi-pattern anonymous functions, especially if we stipulate that
>>> unlike a case (but like a lambda) you can have multiple arguments; then
>>> you could write stuff like:
>>> sumTo0 = foldr (\of 0 k -> 0
>>>                     n k -> n + k) 0
>> sumTo0 = foldr (\0 k -> 0
>>                  n k -> n + k) 0
> foo = getSomethingCPS $ \ arg ->
>       moreStuff
> is now a syntax error (\ { varid -> } matches no productions).
A multi-way lambda could be introduced using \\ thus:

     sumTo0 = foldr (\\ 0 k -> 0; n k -> n + k) 0

[from a previous post]
> It's not like the current language has that property; consider (map
> myFunction) - is that an error or a partial application?

By "construct" I meant only those grammatical elements involving keywords, and was thinking about situations where you might for example have various syntax templates bound to function keys eg in Haskell the following are incomplete:

   case of
   if then else
   data where deriving

("let in" could still be marked as incomplete even if it is ok according to the grammar since it would be weird to bother writing a let with no bindings.)

There is a similar problem with the way template haskell uses unmatched quotes such as 'a so it's no longer possible to determine whether this should be marked as an incomplete character literal or a complete TH name.

I suppose my main point is that it's useful for a syntax to have plenty of "unfilled gaps" that result in an error when written rather than filling all those gaps with different meanings...


More information about the Haskell-Cafe mailing list