How do you print an error from a child thread in Haskell?

Viewed 336

Given the following code:

module Main where

import Control.Concurrent

main :: IO ()
main = forkIO errorPrinter >> threadDelay 1000000 >> print "Finished"

errorPrinter = error "You can't see me!"

I would expect, that upon running this code I would see this:

"You can't see me"
"Finished!"

Printed to the console. However, "You can't see me" is never printed.

I realise that using error is not a good idea in production code, but I use it in development and I find that no errors are printed to the console - even those raised by dependencies.

I am sure this problem has an easy solution. I can't be the first person to have this issue, but I can't find an answer anywhere.

Any help would be much appreciated!

1 Answers
Related