#4359: Implement lambda-case/lambda-if
-------------------------------+--------------------------------------------
Reporter: batterseapower | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 7.6.1
Component: Compiler | Version: 7.1
Resolution: | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
-------------------------------+--------------------------------------------
Comment(by simonpj):
Simon and I have had a chat, and discussed the various alternatives
swirling around. In the interests of deciding ''something'', rather than
continuing an infinite loop of design choices, we propose to adopt:
* `\case`, with exactly the same case alternatives as an ordinary `case`
expression. That is, each alternative has a single un-parenthesised
pattern. Thus
{{{
\case { Just x -> x+1; Nothing -> 0 }
}}}
The `\case` becomes a layout herald. It would be fine if the
implementation does not permit any space between the backslash and the
`case`; but if it's easier to allow space there, that's ok too.
(Personally I'd strongly discourage programmers from using space there.)
* Multi-branch `if`:
{{{
if | x>0 -> -1
| x==0 -> 0
| otherwise -> 1
}}}
No layout here; branches continue (as with guarded case alternatives)
until the next "`|`", and the last branch continues as far as possible
(like the `else` of an `if`).
There are lots and lots of other alternatives, but these choices seem
simple and achieve much of the benefit. If anyone thinks this is so bad
that it's worth continuing the debate, sing out.
mikhail, if you'd like to send a patch (don't forget documentation!) we'll
apply it. Many thanks.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4359#comment:69>
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