@@ -1,44 +1,31 @@
1module Reporting.Progress.Json
1module Reporting.Progress.Json
7−import Control.Concurrent (forkIO)
7+import qualified Data.ByteString.Builder as B
8−import Control.Concurrent.Chan (Chan, newChan, readChan)
8+import System.IO (stderr)
9−import Control.Concurrent.MVar (newEmptyMVar, putMVar)
11import qualified Reporting.Exit as Exit
10import qualified Reporting.Exit as Exit
12import qualified Reporting.Progress as Progress
11import qualified Reporting.Progress as Progress
12+import qualified Json.Encode as Encode
16−-- CREATE
16+-- REPORTER
19−create :: IO Progress.Reporter
19+reporter :: Progress.Reporter
21− do chan <- newChan
21+ Progress.Reporter (\_ -> return ()) end
23− _ <- forkIO (loop chan >>= putMVar mvar)
24− return (Progress.makeReporter chan mvar)
24+end :: Maybe Exit.Exit -> IO ()
28+ B.hPutBuilder stderr (Encode.encodeUgly (Exit.toJson exit))
31−loop :: Chan Progress.Msg -> IO ()
33− do msg <- readChan chan
35− Progress.Progress _ ->
38− Progress.End maybeExit ->
44− return ()
31+ return ()