Skip to content

Commit 575aec3

Browse files
committed
Removing reporting of dependencies, as they're always loaded by the frontend.
1 parent 303eecf commit 575aec3

File tree

8 files changed

+17
-246
lines changed

8 files changed

+17
-246
lines changed

builder/src/Gren/Details.hs

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import Gren.Package qualified as Pkg
4646
import Gren.Platform qualified as P
4747
import Gren.Version qualified as V
4848
import Parse.Module qualified as Parse
49-
import Reporting qualified
5049
import Reporting.Annotation qualified as A
5150
import Reporting.Exit qualified as Exit
5251
import Reporting.Task qualified as Task
@@ -122,24 +121,17 @@ loadInterfaces root (Details _ _ _ _ _ extras) =
122121

123122
-- LOAD -- used by Make, Docs, Repl
124123

125-
load :: Reporting.Style -> Outline.Outline -> Map.Map Pkg.Name Dependency -> IO (Either Exit.Details Details)
126-
load style outline solution =
127-
Reporting.trackDetails style $ \key ->
128-
generate key outline solution
129-
130-
-- GENERATE
131-
132-
generate :: Reporting.DKey -> Outline.Outline -> Map.Map Pkg.Name Dependency -> IO (Either Exit.Details Details)
133-
generate key outline solution =
124+
load :: Outline.Outline -> Map.Map Pkg.Name Dependency -> IO (Either Exit.Details Details)
125+
load outline solution =
134126
case outline of
135127
Outline.Pkg (Outline.PkgOutline pkg _ _ _ exposed direct _ rootPlatform) ->
136128
Task.run $
137129
do
138130
let exposedList = Outline.flattenExposed exposed
139-
verifyDependencies key (ValidPkg rootPlatform pkg exposedList) solution direct
131+
verifyDependencies (ValidPkg rootPlatform pkg exposedList) solution direct
140132
Outline.App (Outline.AppOutline _ rootPlatform srcDirs direct _) ->
141133
Task.run $
142-
verifyDependencies key (ValidApp rootPlatform srcDirs) solution direct
134+
verifyDependencies (ValidApp rootPlatform srcDirs) solution direct
143135

144136
type Task a = Task.Task Exit.Details a
145137

@@ -154,12 +146,12 @@ fork work =
154146

155147
-- VERIFY DEPENDENCIES
156148

157-
verifyDependencies :: Reporting.DKey -> ValidOutline -> Map.Map Pkg.Name Dependency -> Map.Map Pkg.Name a -> Task Details
158-
verifyDependencies key outline solution directDeps =
149+
verifyDependencies :: ValidOutline -> Map.Map Pkg.Name Dependency -> Map.Map Pkg.Name a -> Task Details
150+
verifyDependencies outline solution directDeps =
159151
Task.eio id $
160152
do
161153
mvar <- newEmptyMVar
162-
mvars <- Map.traverseWithKey (\k v -> fork (build key mvar k v)) solution
154+
mvars <- Map.traverseWithKey (\k v -> fork (build mvar k v)) solution
163155
putMVar mvar mvars
164156
deps <- traverse readMVar mvars
165157
case sequence deps of
@@ -221,12 +213,11 @@ type Fingerprint =
221213

222214
-- BUILD
223215

224-
build :: Reporting.DKey -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Pkg.Name -> Dependency -> IO Dep
225-
build key depsMVar pkg (Dependency outline sources) =
216+
build :: MVar (Map.Map Pkg.Name (MVar Dep)) -> Pkg.Name -> Dependency -> IO Dep
217+
build depsMVar pkg (Dependency outline sources) =
226218
case outline of
227219
(Outline.App _) ->
228220
do
229-
Reporting.report key Reporting.DBroken
230221
return $ Left $ Just $ Exit.BD_BadBuild pkg V.one Map.empty
231222
(Outline.Pkg (Outline.PkgOutline _ _ _ _ exposed deps _ platform)) ->
232223
do
@@ -235,7 +226,6 @@ build key depsMVar pkg (Dependency outline sources) =
235226
case sequence directDeps of
236227
Left _ ->
237228
do
238-
Reporting.report key Reporting.DBroken
239229
return $ Left Nothing
240230
Right directArtifacts ->
241231
do
@@ -251,11 +241,9 @@ build key depsMVar pkg (Dependency outline sources) =
251241
case sequence maybeStatuses of
252242
Left CrawlCorruption ->
253243
do
254-
Reporting.report key Reporting.DBroken
255244
return $ Left $ Just $ Exit.BD_BadBuild pkg V.one Map.empty
256245
Left CrawlUnsignedKernelCode ->
257246
do
258-
Reporting.report key Reporting.DBroken
259247
return $ Left $ Just $ Exit.BD_UnsignedBuild pkg V.one
260248
Right statuses ->
261249
do
@@ -266,14 +254,12 @@ build key depsMVar pkg (Dependency outline sources) =
266254
case sequence maybeResults of
267255
Nothing ->
268256
do
269-
Reporting.report key Reporting.DBroken
270257
return $ Left $ Just $ Exit.BD_BadBuild pkg V.one Map.empty
271258
Just results ->
272259
let ifaces = gatherInterfaces exposedDict results
273260
objects = gatherObjects results
274261
artifacts = Artifacts ifaces objects
275262
in do
276-
Reporting.report key Reporting.DBuilt
277263
return (Right artifacts)
278264

279265
-- GATHER

builder/src/Reporting.hs

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ module Reporting
1515
ignorer,
1616
ask,
1717
--
18-
DKey,
19-
DMsg (..),
20-
trackDetails,
21-
--
2218
BKey,
2319
BMsg (..),
2420
trackBuild,
@@ -31,14 +27,10 @@ where
3127

3228
import Control.Concurrent
3329
import Control.Exception (AsyncException (UserInterrupt), SomeException, catch, fromException, throw)
34-
import Control.Monad (when)
3530
import Data.ByteString.Builder qualified as B
3631
import Data.NonEmptyList qualified as NE
3732
import Gren.ModuleName qualified as ModuleName
38-
import Gren.Package qualified as Pkg
39-
import Gren.Version qualified as V
4033
import Json.Encode qualified as Encode
41-
import Reporting.Doc ((<+>))
4234
import Reporting.Doc qualified as D
4335
import Reporting.Exit qualified as Exit
4436
import Reporting.Exit.Help qualified as Help
@@ -102,14 +94,6 @@ attemptWithStyle style toReport work =
10294

10395
-- MARKS
10496

105-
goodMark :: D.Doc
106-
goodMark =
107-
D.green $ if isWindows then "+" else ""
108-
109-
badMark :: D.Doc
110-
badMark =
111-
D.red $ if isWindows then "X" else ""
112-
11397
isWindows :: Bool
11498
isWindows =
11599
Info.os == "mingw32"
@@ -151,122 +135,6 @@ askHelp =
151135
putStr "Must type 'y' for yes or 'n' for no: "
152136
askHelp
153137

154-
-- DETAILS
155-
156-
type DKey = Key DMsg
157-
158-
trackDetails :: Style -> (DKey -> IO a) -> IO a
159-
trackDetails style callback =
160-
case style of
161-
Silent ->
162-
callback (Key (\_ -> return ()))
163-
Json ->
164-
callback (Key (\_ -> return ()))
165-
Terminal mvar ->
166-
do
167-
chan <- newChan
168-
169-
_ <- forkIO $
170-
do
171-
takeMVar mvar
172-
detailsLoop chan (DState 0 0 0 0 0 0 0)
173-
putMVar mvar ()
174-
175-
answer <- callback (Key (writeChan chan . Just))
176-
writeChan chan Nothing
177-
return answer
178-
179-
detailsLoop :: Chan (Maybe DMsg) -> DState -> IO ()
180-
detailsLoop chan state@(DState total _ _ _ _ built _) =
181-
do
182-
msg <- readChan chan
183-
case msg of
184-
Just dmsg ->
185-
detailsLoop chan =<< detailsStep dmsg state
186-
Nothing ->
187-
putStrLn $
188-
clear (toBuildProgress total total) $
189-
if built == total
190-
then "Dependencies ready!"
191-
else "Dependency problem!"
192-
193-
data DState = DState
194-
{ _total :: !Int,
195-
_cached :: !Int,
196-
_requested :: !Int,
197-
_received :: !Int,
198-
_failed :: !Int,
199-
_built :: !Int,
200-
_broken :: !Int
201-
}
202-
203-
data DMsg
204-
= DStart Int
205-
| DCached
206-
| DRequested
207-
| DReceived Pkg.Name V.Version
208-
| DFailed Pkg.Name V.Version
209-
| DBuilt
210-
| DBroken
211-
212-
detailsStep :: DMsg -> DState -> IO DState
213-
detailsStep msg (DState total cached rqst rcvd failed built broken) =
214-
case msg of
215-
DStart numDependencies ->
216-
return (DState numDependencies 0 0 0 0 0 0)
217-
DCached ->
218-
putTransition (DState total (cached + 1) rqst rcvd failed built broken)
219-
DRequested ->
220-
do
221-
when (rqst == 0) (putStrLn "Starting downloads...\n")
222-
return (DState total cached (rqst + 1) rcvd failed built broken)
223-
DReceived pkg vsn ->
224-
do
225-
putDownload goodMark pkg vsn
226-
putTransition (DState total cached rqst (rcvd + 1) failed built broken)
227-
DFailed pkg vsn ->
228-
do
229-
putDownload badMark pkg vsn
230-
putTransition (DState total cached rqst rcvd (failed + 1) built broken)
231-
DBuilt ->
232-
putBuilt (DState total cached rqst rcvd failed (built + 1) broken)
233-
DBroken ->
234-
putBuilt (DState total cached rqst rcvd failed built (broken + 1))
235-
236-
putDownload :: D.Doc -> Pkg.Name -> V.Version -> IO ()
237-
putDownload mark pkg vsn =
238-
Help.toStdout $
239-
D.indent 2 $
240-
mark
241-
<+> D.fromPackage pkg
242-
<+> D.fromVersion vsn
243-
<> "\n"
244-
245-
putTransition :: DState -> IO DState
246-
putTransition state@(DState total cached _ rcvd failed built broken) =
247-
if cached + rcvd + failed < total
248-
then return state
249-
else do
250-
let char = if rcvd + failed == 0 then '\r' else '\n'
251-
putStrFlush (char : toBuildProgress (built + broken + failed) total)
252-
return state
253-
254-
putBuilt :: DState -> IO DState
255-
putBuilt state@(DState total cached _ rcvd failed built broken) =
256-
do
257-
when (total == cached + rcvd + failed) $
258-
putStrFlush $
259-
'\r' : toBuildProgress (built + broken + failed) total
260-
return state
261-
262-
toBuildProgress :: Int -> Int -> [Char]
263-
toBuildProgress built total =
264-
"Verifying dependencies (" ++ show built ++ "/" ++ show total ++ ")"
265-
266-
clear :: [Char] -> [Char] -> [Char]
267-
clear before after =
268-
'\r' : replicate (length before) ' ' ++ '\r' : after
269-
270138
-- BUILD
271139

272140
type BKey = Key BMsg

terminal/Docs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ runHelp :: Reporting.Style -> Flags -> IO (Either Exit.Docs ())
5555
runHelp style (Flags maybeOutput _ root outline sources dependencies) =
5656
Task.run $
5757
do
58-
details <- Task.eio Exit.DocsBadDetails (Details.load style outline dependencies)
58+
details <- Task.eio Exit.DocsBadDetails (Details.load outline dependencies)
5959
exposed <- getExposed details
6060
case maybeOutput of
6161
Just DevNull ->

terminal/Make.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ run flags@(Flags _ _ maybeOutput report _ _ _ _ _) =
6666
do
6767
style <- getStyle maybeOutput report
6868
-- TODO: File locking in frontend
69-
-- TODO: Show error for Exit.MakeNoOutline in frontend
7069
Reporting.attemptWithStyle style Exit.makeToReport $
7170
runHelp style flags
7271

@@ -75,7 +74,7 @@ runHelp style flags@(Flags optimize withSourceMaps maybeOutput _ modules root ou
7574
Task.run $
7675
do
7776
desiredMode <- getMode optimize
78-
details <- Task.eio Exit.MakeBadDetails (Details.load style outline deps)
77+
details <- Task.eio Exit.MakeBadDetails (Details.load outline deps)
7978
let platform = getPlatform details
8079
case modules of
8180
[] ->

terminal/Package/Bump.hs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE OverloadedStrings #-}
2+
{-# OPTIONS_GHC -Wno-x-partial #-}
23

34
module Package.Bump
45
( run,
@@ -51,7 +52,7 @@ run flags@(Flags _ _ _ currentVersion publishedVersion) =
5152
-- BUMP
5253

5354
bump :: Flags -> Outline.PkgOutline -> Outline.PkgOutline -> Task.Task Exit.Bump ()
54-
bump flags@(Flags _ root knownVersions _ _) currentOutline@(Outline.PkgOutline _ _ _ vsn _ _ _ _) publishedOutline =
55+
bump flags@(Flags _ _ knownVersions _ _) currentOutline@(Outline.PkgOutline _ _ _ vsn _ _ _ _) publishedOutline =
5556
Task.eio id $
5657
case reverse knownVersions of
5758
(v : vs) ->
@@ -67,21 +68,6 @@ bump flags@(Flags _ root knownVersions _ _) currentOutline@(Outline.PkgOutline _
6768
[] ->
6869
error "known versions was empty"
6970

70-
-- CHECK NEW PACKAGE
71-
72-
checkNewPackage :: Flags -> FilePath -> Outline.PkgOutline -> IO ()
73-
checkNewPackage flags root outline@(Outline.PkgOutline _ _ _ version _ _ _ _) =
74-
do
75-
putStrLn Exit.newPackageOverview
76-
if version == V.one
77-
then putStrLn "The version number in gren.json is correct so you are all set!"
78-
else
79-
changeVersion flags root outline V.one $
80-
"It looks like the version in gren.json has been changed though!\n\
81-
\Would you like me to change it back to "
82-
<> D.fromVersion V.one
83-
<> "? [Y/n] "
84-
8571
-- SUGGEST VERSION
8672

8773
suggestVersion :: Flags -> Outline.PkgOutline -> Outline.PkgOutline -> Task.Task Exit.Bump ()
@@ -116,7 +102,7 @@ generateDocs root outline@(Outline.PkgOutline _ _ _ _ exposed _ _ _) sources sol
116102
do
117103
details <-
118104
Task.eio Exit.BumpBadDetails $
119-
Details.load Reporting.silent (Outline.Pkg outline) solution
105+
Details.load (Outline.Pkg outline) solution
120106

121107
case Outline.flattenExposed exposed of
122108
[] ->

terminal/Package/Diff.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ generateDocs root outline@(Outline.PkgOutline _ _ _ _ exposed _ _ _) sources sol
7070
do
7171
details <-
7272
Task.eio Exit.DiffBadDetails $
73-
Details.load Reporting.silent (Outline.Pkg outline) solution
73+
Details.load (Outline.Pkg outline) solution
7474

7575
case Outline.flattenExposed exposed of
7676
[] ->

0 commit comments

Comments
 (0)