on 1c91efd help sign in
elk/builder/src/Reporting/Progress.hs
117 lines 2.1 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Progress
3 ( Reporter(..)
4 , makeReporter
5 , silentReporter
6 , Msg(..)
7 , Progress(..)
8 , Outcome(..)
9 , PublishPhase(..)
10 , BumpPhase(..)
11 )
12 where
15import Control.Concurrent.Chan (Chan, writeChan)
16import Control.Concurrent.MVar (MVar, newEmptyMVar, readMVar)
17import qualified Elm.Compiler.Module as Module
18import Deps.Diff (Magnitude)
19import Elm.Package (Name, Version)
20import qualified Reporting.Doc as D
21import Reporting.Exit (Exit)
25-- REPORTER
28data Reporter =
29 Reporter
30 { _tell :: Progress -> IO ()
31 , _ask :: D.Doc -> IO Bool
32 , _end :: Maybe Exit -> IO ()
33 }
36makeReporter :: Chan Msg -> MVar () -> Reporter
37makeReporter chan mvar =
38 let
39 tell progress =
40 writeChan chan (Progress progress)
42 ask doc =
43 do var <- newEmptyMVar
44 writeChan chan (Ask doc var)
45 readMVar var
47 end maybeError =
48 do writeChan chan (End maybeError)
49 readMVar mvar
50 in
51 Reporter tell ask end
54silentReporter :: Reporter
55silentReporter =
56 Reporter
57 (\_ -> return ())
58 (\_ -> return True)
59 (\_ -> return ())
63-- MESSAGES
66data Msg
67 = Progress Progress
68 | Ask D.Doc (MVar Bool)
69 | End (Maybe Exit)
72data Progress
73 -- download packages
74 = DownloadSkip
75 | DownloadStart [(Name, Version)]
76 | DownloadPkgStart Name Version
77 | DownloadPkgEnd Name Version Outcome
78 | DownloadEnd Outcome
80 -- build dependencies
81 | BuildDepsStart Int
82 | BuildDepsProgress
83 | BuildDepsEnd
85 -- compile files
86 | CompileStart Int
87 | CompileFileStart Module.Raw
88 | CompileFileEnd Module.Raw Outcome
89 | CompileEnd
91 -- publish
92 | PublishStart Name Version (Maybe [Version])
93 | PublishCheckBump Version BumpPhase
94 | PublishProgress PublishPhase (Maybe Outcome)
95 | PublishEnd
97 -- solver
98 | UnableToLoadLatestPackages
101data Outcome = Good | Bad
104data PublishPhase
105 = CheckReadme
106 | CheckLicense
107 | CheckTag Version
108 | CheckDownload
109 | CheckBuild
110 | CheckChanges
113data BumpPhase
114 = StatedVersion
115 | GoodStart
116 | GoodBump Version Magnitude
117 | BadBump