#4359: Implement lambda-case/lambda-if
---------------------------------+------------------------------------------
Reporter: batterseapower | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.4.1
Component: Compiler | Version: 7.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by simonmar):
Having re-read the Haskell cafe thread and after discussing this with
Simon yesterday, I'm convinced that the multi-clause lambda approach is
the cleanest extension of the language.
* `\case` is out: either it supports a single-argument lambda only, which
would be inconsistent with `\`, or it supports multi-argument lambda,
which would be inconsistent with `case`.
* `|` to separate clauses is out: `|` is already used for guards, so this
is an inconsistency
* `,` to separate arguments is out: nowhere else in the syntax uses comma
to separate arguments
* `case of` is out: it doesn't look like a lambda (I don't buy the
partial application argument of comment:18, since for there to be a
partial application there has to be a function, and there isn't one here)
In favour of multi-clause lambda:
* it is more generally useful than `mcase` or `case<-`.
Against:
* It is a change to the syntax. But it will be optional, so it only
breaks existing code if you explicitly enable it.
Arguably having `\` introduce layout is an improvement, because it
enforces the requirement that the lambda binding scopes over code to the
right and below.
There is one alternative design that does make sense: leave `\` as it is
and choose a new keyword for multi-clause lambda, e.g. `fun` (or,
cheekily, `λ`). This would have the disadvantage that there would be two
constructs for anonymous functions (too much syntax), I think we should
try out multi-clause `\` first and see how well it works in practice.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4359#comment:24>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs