#5560: case and type synonym
------------------------------------------+---------------------------------
  Reporter:  sleepyMonad                  |          Owner:        
      Type:  bug                          |         Status:  closed
  Priority:  normal                       |      Milestone:        
 Component:  Compiler                     |        Version:  7.0.2 
Resolution:  invalid                      |       Keywords:        
  Testcase:                               |      Blockedby:        
Difficulty:                               |             Os:  Linux 
  Blocking:                               |   Architecture:  x86   
   Failure:  Incorrect result at runtime  |  
------------------------------------------+---------------------------------
Changes (by igloo):

  * status:  new => closed
  * resolution:  => invalid


Comment:

 Pattern matching doesn't work like that I'm afraid. If you use the `-Wall`
 flag then you will get some extra warnings like
 {{{
 q.hs:12:16:
     Warning: This binding for `kp' shadows the existing binding
                defined at q.hs:7:1

 q.hs:12:16: Warning: Defined but not used: `kp'
 }}}

 Your definition of `switchOnEvent2` is equivalent to
 {{{
 switchOnEvent2 :: MyEventType -> IO ()
 switchOnEvent2 x = do putStrLn "KP"
 switchOnEvent2 y = do putStrLn "BP"
 switchOnEvent2 _ = do putStrLn "??"
 }}}

 You may want something like
 {{{
 switchOnEvent2 :: MyEventType -> IO ()
 switchOnEvent2 e
  | e == kp   = do putStrLn "KP"
  | e == bp   = do putStrLn "BP"
  | otherwise = do putStrLn "??"
 }}}

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