#836: rebindable if-then-else syntax
----------------------------------+-----------------------------------------
    Reporter:  nibro              |        Owner:              
        Type:  feature request    |       Status:  new         
    Priority:  normal             |    Milestone:  _|_         
   Component:  Compiler (Parser)  |      Version:  6.13        
    Keywords:                     |     Testcase:  N/A         
   Blockedby:                     |   Difficulty:  Unknown     
          Os:  Unknown/Multiple   |     Blocking:              
Architecture:  Unknown/Multiple   |      Failure:  None/Unknown
----------------------------------+-----------------------------------------

Comment(by simonpj):

 The main ticket is, I believe, suggesting that when rebindable syntax is
 enabled, then whenever GHC sees
 {{{
 if e1 then e2 else e3
 }}}
 it behaves precisely as if you'd written
 {{{
 cond e1 e2 e3
 }}}
 from ''both'' the point of view of typechecking, ''and'' the point of view
 of desugaring.  So, for example if
 {{{
 cond :: Bool -> Int -> Char
 }}}
 then you could write
 {{{
 if x>y then 3 else 'c'
 }}}
 That seems entirely feasible to me.   The question of overloading then
 becomes quite orthogonal.  For example, if the imported `cond` had this
 type:
 {{{
 cond :: IfThenElse a => Bool -> a -> a -> a
 }}}
 then that'd be fine.  The term `if e1 then e2 else e3` would typecheck and
 desugar as if you'd written `cond e1 e2 e3`.  I think that would satisfy
 vivian without any need for special support.

 My main question is this: what about `case`?  The proposal would mean that
 `if-then-else` was different to
 {{{
 case e1 of
   True -> e2
   False -> e3
 }}}
 Maybe that's ok.  Maybe it's even desirable.  But I don't see how to
 generalise the story to case expressions, at least not without a lot more
 elaboration.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/836#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to