
On 06/10/2010 00:04, Max Bolingbroke wrote:
On 5 October 2010 17:38, Henning Thielemann
wrote: Richard O'Keefe schrieb:
I'd prefer to see something like \ 1 -> f | 2 -> g but I'm sure something could be worked out.
In order to be consistent with current case, maybe in layout mode:
\1 -> f 2 -> g
and in non-layout mode
\{1 -> f; 2 -> g}
Duncan Coutts also suggested this possibility to me - once I saw it actually liked it rather better than the lambda-case stuff, particularly since it generalises nicely to multiple arguments. I may try to write a patch for this extension instead when I get some free time.
A slightly different suggestion from Simon PJ and myself (we agreed on something syntax-related :-) is the following: \case 1 -> f 2 -> g where the two-token sequence '\ case' introduces a new optional layout context, the body of which is exactly the same as in a case expression. So you could also write \case { 1 -> f; 2 -> g } if you want. Guards are allowed of course. The motivation for this syntax is: * easy to mentally parse: \ still introduces a function. (better than 'case of' in this respect) * a bit more noisy than just \: I'm not sure what the ramifications of having \ introduce a layout context on its own would be, but I suspect there would be difficulties. Certainly some existing code would fail to parse, e.g. (case e of [] -> \x -> x+1; (x:xs) -> \x -> x+2) Cheers, Simon