forkThread :: IO () -> IO (MVar ())
forkThread proc = do handle <- newEmptyMVar
                     _ <- forkFinally proc (\_ -> putMVar handle ())
                     return handle
forkThread :: IO () -> IO (MVar ())
forkThread proc = do handle <- newEmptyMVar
                     _ <- forkFinally proc (\_ -> putMVar handle ())
                     return handle
forkThread proc = do handle <- newEmptyMVar
                     _ <- forkFinally proc (\_ -> putMVar handle ())
                     return handle