I have a function like:
type App a = ExceptT AppError (ResourceT IO)
onEvent :: SDL.EventPayload -> App ()
onEvent event = do
liftIO $ putStrLn "EVE!"
case event of
SDL.MouseMotionEvent dat -> do
liftIO $ putStrLn "HELLO"
SDL.KeyboardEvent kbe -> liftIO $ putStrLn "WORLD"
_ -> return ()
That is a callback being used in my app.
This function seemingly doesn't fire, Because none of the putStrLn's print to console.
But this function - with the slight modification does print everything to console:
onEvent :: SDL.EventPayload -> App ()
onEvent event = do
liftIO $ putStrLn "EVE!"
case event of
SDL.MouseMotionEvent dat -> do
liftIO $ print dat
SDL.KeyboardEvent kbe -> liftIO $ print kbe
_ -> return ()
Why does the full evaluation of SDL.EventPayload
cause the surrounding putStrLn
's to work?
How can I make my function callback a bit more reliable?
hPutStrLn stderr
instead.