handleEvents :: (Event -> Z ()) -> WS.Connection -> Z ()
handleEvents directives ws = do
  raw <- liftIO $ WS.receiveData ws
  case eitherDecode raw of
    Left e -> liftIO $ do
      putStrLn $ "Failed to parse event: " ++ e
      BC.putStrLn $ pprint raw
      putStrLn ""
    Right event -> directives event
handleEvents :: (Event -> Z ()) -> WS.Connection -> Z ()
handleEvents directives ws = do
  raw <- liftIO $ WS.receiveData ws
  case eitherDecode raw of
    Left e -> liftIO $ do
      putStrLn $ "Failed to parse event: " ++ e
      BC.putStrLn $ pprint raw
      putStrLn ""
    Right event -> directives event
handleEvents directives ws = do
  raw <- liftIO $ WS.receiveData ws
  case eitherDecode raw of
    Left e -> liftIO $ do
      putStrLn $ "Failed to parse event: " ++ e
      BC.putStrLn $ pprint raw
      putStrLn ""
    Right event -> directives event