GHC.Conc.threadStatus - documentation of ThreadDied :: ThreadStatus
Summary
Location of documentation issue: Haddocks for GHC.Conc
The documentation for GHC.Conc.ThreadStatus says:
ThreadDied -- the thread received an uncaught exception
The emphasis should be on received here, because a thread that is created with GHC.Conc.forkIO
and that internally throws an exception is reported as having the ThreadStatus
ThreadFinished
. Only exceptions provoked by GHC.Conc.throwTo
result in ThreadDied
.
Minimal working example:
import Control.Concurrent
import GHC.Conc
main = mainThread
childThread :: IO ()
childThread = fail "child thread is crashing!"
mainThread :: IO ()
mainThread = do
child <- forkIO childThread
threadDelay 5000
status <- threadStatus child
putStr "The status of my child is: "
print status
Proposed improvements or changes
Proposals in order of disruptivity.
- At least the documentation should clarify this.
- One could change the semantics of
GHC.Conc.threadStatus
to make the above example printThreadDied
, too. - One might not change the semantics of
GHC.Conc.threadStatus
but re-name the constuctorThreadDied
to properly reflect its behaviour.
Environment
- GHC version used (if appropriate):
9.0.2