Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. handleMsg :: Handle -> VM -> String -> IO ()
  2. handleMsg clientHandle vm msg = do
  3. let splitMsg = words msg
  4. let action = splitMsg !! 0
  5. case lookup action of
  6. Just f -> f clientHandle vm splitMsg
  7. Nothing -> putStrLn $ "unknown action " ++ action
  8.  
  9. messageHandlers :: [(String, Handle -> VM -> [String] -> IO ())]
  10. messageHandlers = [("update", handleUpdate),
  11. ("key_down", handleKeyDown),
  12. ("key_up", handleKeyUp),
  13. ("pointer", handlePointer)]
  14.  
  15. {-----------------------------}
  16.  
  17. Main.hs:76:8:
  18. Couldn't match expected type `[(String, b)] -> Maybe b'
  19. against inferred type `Maybe a'
  20. In the pattern: Just f
  21. In a case alternative: Just f -> f clientHandle vm splitMsg
  22. In the expression:
  23. case lookup action of {
  24. Just f -> f clientHandle vm splitMsg
  25. Nothing -> putStrLn $ "unknown action " ++ (splitMsg !! 0) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement