#4359: Implement lambda-case/lambda-if
---------------------------------+------------------------------------------
    Reporter:  batterseapower    |        Owner:  igloo       
        Type:  feature request   |       Status:  patch       
    Priority:  high              |    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 mikhail.vorozhtsov):

 Replying to [comment:48 simonpj]:
 > Thus:
 > {{{
 >    \ { True -> e1; False -> e2 }
 > }}}
 > would be ok.  But this would not be ok
 > {{{
 >     \ True -> e1
 >       False -> e2
 > }}}
 > That seems like a reasonable compromise.  Using the brace/semicolon
 stuff is compatible with the way case expressions work, which is a Good
 Thing.  Any comments?

 Ugh. This is getting uglier and uglier. I've been using the current
 version of the patch for some time and I think the syntax has two major
 problems:

 1. It rejects the nice-looking indentation we are all used to in the
 single-clause case (see my 'mask' example above).

 2. It looks like a case expression, but has different pattern syntax, i.e.
 I constantly write
 {{{
 foo >>= \
   Nothing -> ...
   Just a  -> ...
 }}}
 instead of the correct
 {{{
 foo >>= \
   Nothing  -> ...
   (Just a) -> ...
 }}}

 Explicit layout solves the first issue, IMO, at the expense of graphic
 clarity. I mean
 {{{
 foo >>= \
   { Nothing  -> do
       abc
       def
   ; (Just a) -> do
       abc
       def
   }
 }}}
 just makes my eyes hurt. Do we really want a feature that is only
 accessible using explicit layout?

 I think the fact that single- and multi-clause lambdas require different
 indentation rules (and we can't look ahead to distinguish them) tells us
 to use a different token (\fn, \fun, \let?). I'd also say that {{{\x ->
 case x of ...}}} (or {{{x <- foo; case x of ...}}}) is such a common idiom
 that it deserves its "anonymous" counterpart (with respect to pattern
 syntax) regardless of the whole multi-clause lambda thing.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4359#comment:49>
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

Reply via email to