on 2ea433c help sign in
elk/builder/src/Reporting/Progress.hs
98 lines 1.7 kB history raw
1{-# OPTIONS_GHC -Wall #-}
2module Reporting.Progress
3 ( Reporter(..)
4 , makeReporter
5 , Msg(..)
6 , Progress(..)
7 , Outcome(..)
8 , PublishPhase(..)
9 , BumpPhase(..)
10 )
11 where
14import Control.Concurrent.Chan (Chan, writeChan)
15import Control.Concurrent.MVar (MVar, readMVar)
16import qualified Elm.Compiler.Module as Module
17import Deps.Diff (Magnitude)
18import Elm.Package (Name, Version)
19import Reporting.Error2 (Error)
23-- REPORTER
26data Reporter =
27 Reporter
28 { _tell :: Progress -> IO ()
29 , _end :: Maybe Error -> IO ()
30 }
33makeReporter :: Chan Msg -> MVar () -> Reporter
34makeReporter chan mvar =
35 let
36 tell progress =
37 writeChan chan (Progress progress)
39 end maybeError =
40 do writeChan chan (End maybeError)
41 readMVar mvar
42 in
43 Reporter tell end
47-- MESSAGES
50data Msg = Progress Progress | End (Maybe Error)
53data Progress
54 -- download packages
55 = DownloadSkip
56 | DownloadStart [(Name, Version)]
57 | DownloadPkgStart Name Version
58 | DownloadPkgEnd Name Version Outcome
59 | DownloadEnd Outcome
61 -- build dependencies
62 | BuildDepsStart Int
63 | BuildDepsProgress
64 | BuildDepsEnd
66 -- compile files
67 | CompileStart Int
68 | CompileFileStart Module.Raw
69 | CompileFileEnd Module.Raw Outcome
70 | CompileEnd
72 -- publish
73 | PublishStart Name Version (Maybe [Version])
74 | PublishCheckBump Version BumpPhase
75 | PublishProgress PublishPhase (Maybe Outcome)
76 | PublishEnd
78 -- solver
79 | UnableToLoadLatestPackages
82data Outcome = Good | Bad
85data PublishPhase
86 = CheckReadme
87 | CheckLicense
88 | CheckTag Version
89 | CheckDownload
90 | CheckBuild
91 | CheckChanges
94data BumpPhase
95 = StatedVersion
96 | GoodStart
97 | GoodBump Version Magnitude
98 | BadBump