on 233cfc8 help sign in
elk/builder/src/Reporting/Progress.hs
121 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 -- elm.json
74 = ElmJsonApproved
75 | ElmJsonRejected
77 -- download packages
78 | DownloadSkip
79 | DownloadStart [(Name, Version)]
80 | DownloadPkgStart Name Version
81 | DownloadPkgEnd Name Version Outcome
82 | DownloadEnd Outcome
84 -- build dependencies
85 | BuildDepsStart Int
86 | BuildDepsProgress
87 | BuildDepsEnd
89 -- compile files
90 | CompileStart Int
91 | CompileFileStart Module.Raw
92 | CompileFileEnd Module.Raw Outcome
93 | CompileEnd
95 -- publish
96 | PublishStart Name Version (Maybe [Version])
97 | PublishCheckBump Version BumpPhase
98 | PublishProgress PublishPhase (Maybe Outcome)
99 | PublishEnd
101 -- solver
102 | UnableToLoadLatestPackages
105data Outcome = Good | Bad
108data PublishPhase
109 = CheckReadme
110 | CheckLicense
111 | CheckTag Version
112 | CheckDownload
113 | CheckBuild
114 | CheckChanges
117data BumpPhase
118 = StatedVersion
119 | GoodStart
120 | GoodBump Version Magnitude
121 | BadBump