on 6a96e21 help sign in
44 lines 815 B history raw
1module Reporting.Progress.Repl
2 ( create
3 )
4 where
7import Control.Concurrent (forkIO)
8import Control.Concurrent.Chan (Chan, newChan, readChan)
9import Control.Concurrent.MVar (newEmptyMVar, putMVar)
11import qualified Reporting.Exit as Exit
12import qualified Reporting.Progress as Progress
16-- CREATE
19create :: IO Progress.Reporter
20create =
21 do chan <- newChan
22 mvar <- newEmptyMVar
23 _ <- forkIO (loop chan >>= putMVar mvar)
24 return (Progress.makeReporter chan mvar)
28-- LOOP
31loop :: Chan Progress.Msg -> IO ()
32loop chan =
33 do msg <- readChan chan
34 case msg of
35 Progress.Progress _ ->
36 loop chan
38 Progress.End maybeExit ->
39 case maybeExit of
40 Just exit ->
41 Exit.toStderr exit
43 Nothing ->
44 return ()