#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 vivian):

 I think of 'if then else' as less fundamental than 'case' and so the last
 point seems to not be a problem.

 If "if then else" is bound to '''the''' in scope variable 'cond' then 'if
 then else' can't be used in two different ways in the same module, which
 is why I suggested class overloading, which can select the appropriate
 instance from the return type in the context.

 LogicT defines a 'soft cut', which is similar to
 {{{
 condition :: (Error e, Monad m)
           => ErrorT e m a -> (b -> ErrorT e m a) -> ErrorT e m a -> Error
 T e m a
 condition e1 e2 e3 = ErrorT $ do
                               b <- runErrrorT e1
                               case b of
                                      Left _   -> runErrorT e3
                                      Right b' -> runErrorT (e2 b')
 }}}
 and it would nice to be able to rebind this to "if then else"

 A contrived example:
 {{{
 loadDefaults filename = if (openFile filename)
                            then (\handle -> do
                                             version <- loadConfiguration
 handle
                                             if version < 2
                                                then addNewFeatures
                                                else $ return ())
                            else defaultConfiguration
 }}}

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