File: Utils.hs

package info (click to toggle)
haskell-process-extras 0.7.4-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 144 kB
  • sloc: haskell: 729; makefile: 2
file content (10 lines) | stat: -rw-r--r-- 288 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
module Utils where

import Control.Concurrent
import Control.Exception

forkWait :: IO a -> IO (IO a)
forkWait a = do
  res <- newEmptyMVar
  _ <- mask $ \restore -> forkIO $ try (restore a) >>= putMVar res
  return (takeMVar res >>= either (\ex -> throwIO (ex :: SomeException)) return)