Skip to content

Commit 0d55400

Browse files
committed
Merge remote-tracking branch 'origin/master' into 97-guida-format
Conflicts: src/Builder/Elm/Details.elm
2 parents c477391 + 4ace2ce commit 0d55400

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1362
-1384
lines changed

src/Browser/Install.elm

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ import Builder.Elm.Details as Details
77
import Builder.Elm.Outline as Outline
88
import Builder.Reporting as Reporting
99
import Builder.Reporting.Exit as Exit
10-
import Builder.Reporting.Task as Task
1110
import Builder.Stuff as Stuff
1211
import Compiler.Elm.Constraint as C
1312
import Compiler.Elm.Package as Pkg
1413
import Compiler.Elm.Version as V
1514
import Data.Map as Dict exposing (Dict)
16-
import System.IO as IO exposing (IO)
15+
import System.IO as IO
16+
import Task exposing (Task)
1717
import Utils.Main as Utils exposing (FilePath)
18+
import Utils.Task.Extra as Task
1819

1920

2021

2122
-- RUN
2223

2324

24-
run : Pkg.Name -> IO ()
25+
run : Pkg.Name -> Task Never ()
2526
run pkg =
2627
Reporting.attempt Exit.installToReport
2728
(Stuff.findRoot
28-
|> IO.bind
29+
|> Task.bind
2930
(\maybeRoot ->
3031
case maybeRoot of
3132
Nothing ->
32-
IO.pure (Err Exit.InstallNoOutline)
33+
Task.pure (Err Exit.InstallNoOutline)
3334

3435
Just root ->
3536
Task.run
@@ -65,11 +66,7 @@ type Changes vsn
6566
| Changes Outline.Outline
6667

6768

68-
type alias Task a =
69-
Task.Task Exit.Install a
70-
71-
72-
attemptChanges : String -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task ()
69+
attemptChanges : String -> Solver.Env -> Outline.Outline -> (a -> String) -> Changes a -> Task Exit.Install ()
7370
attemptChanges root env oldOutline _ changes =
7471
case changes of
7572
AlreadyInstalled ->
@@ -85,23 +82,23 @@ attemptChanges root env oldOutline _ changes =
8582
attemptChangesHelp root env oldOutline newOutline
8683

8784

88-
attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task ()
85+
attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Install ()
8986
attemptChangesHelp root env oldOutline newOutline =
9087
Task.eio Exit.InstallBadDetails <|
9188
BW.withScope
9289
(\scope ->
9390
Outline.write root newOutline
94-
|> IO.bind (\_ -> Details.verifyInstall scope root env newOutline)
95-
|> IO.bind
91+
|> Task.bind (\_ -> Details.verifyInstall scope root env newOutline)
92+
|> Task.bind
9693
(\result ->
9794
case result of
9895
Err exit ->
9996
Outline.write root oldOutline
100-
|> IO.fmap (\_ -> Err exit)
97+
|> Task.fmap (\_ -> Err exit)
10198

10299
Ok () ->
103100
IO.putStrLn "Success!"
104-
|> IO.fmap (\_ -> Ok ())
101+
|> Task.fmap (\_ -> Ok ())
105102
)
106103
)
107104

@@ -110,7 +107,7 @@ attemptChangesHelp root env oldOutline newOutline =
110107
-- MAKE APP PLAN
111108

112109

113-
makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task (Changes V.Version)
110+
makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task Exit.Install (Changes V.Version)
114111
makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline elmVersion sourceDirs direct indirect testDirect testIndirect) as outline) =
115112
if Dict.member identity pkg direct then
116113
Task.pure AlreadyInstalled
@@ -191,7 +188,7 @@ makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline el
191188
-- MAKE PACKAGE PLAN
192189

193190

194-
makePkgPlan : Solver.Env -> Pkg.Name -> Outline.PkgOutline -> Task (Changes C.Constraint)
191+
makePkgPlan : Solver.Env -> Pkg.Name -> Outline.PkgOutline -> Task Exit.Install (Changes C.Constraint)
195192
makePkgPlan (Solver.Env cache _ connection registry) pkg (Outline.PkgOutline name summary license version exposed deps test elmVersion) =
196193
if Dict.member identity pkg deps then
197194
Task.pure AlreadyInstalled

src/Browser/Main.elm

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,26 @@ import Compiler.Json.Encode as E
1010
import Compiler.Parse.Primitives as P
1111
import Json.Decode as Decode
1212
import Json.Encode as Encode
13-
import System.IO as IO exposing (IO)
13+
import System.IO as IO
14+
import Task exposing (Task)
1415
import Utils.Impure as Impure
16+
import Utils.Task.Extra as Task
1517

1618

1719
main : IO.Program
1820
main =
1921
IO.run app
2022

2123

22-
app : IO ()
24+
app : Task Never ()
2325
app =
2426
getArgs
25-
|> IO.bind
27+
|> Task.bind
2628
(\args ->
2729
case args of
2830
MakeArgs path debug optimize withSourceMaps ->
2931
Make.run path (Make.Flags debug optimize withSourceMaps)
30-
|> IO.bind
32+
|> Task.bind
3133
(\result ->
3234
case result of
3335
Ok output ->
@@ -49,7 +51,7 @@ app =
4951
case P.fromByteString Pkg.parser Tuple.pair pkgString of
5052
Ok pkg ->
5153
Install.run pkg
52-
|> IO.bind (\_ -> exitWithResponse Encode.null)
54+
|> Task.bind (\_ -> exitWithResponse Encode.null)
5355

5456
Err _ ->
5557
exitWithResponse (Encode.object [ ( "error", Encode.string "Invalid package..." ) ])
@@ -58,19 +60,19 @@ app =
5860
case P.fromByteString Pkg.parser Tuple.pair pkgString of
5961
Ok pkg ->
6062
Uninstall.run pkg
61-
|> IO.bind (\_ -> exitWithResponse Encode.null)
63+
|> Task.bind (\_ -> exitWithResponse Encode.null)
6264

6365
Err _ ->
6466
exitWithResponse (Encode.object [ ( "error", Encode.string "Invalid package..." ) ])
6567
)
6668

6769

68-
getArgs : IO Args
70+
getArgs : Task Never Args
6971
getArgs =
7072
Impure.task "getArgs" [] Impure.EmptyBody (Impure.DecoderResolver argsDecoder)
7173

7274

73-
exitWithResponse : Encode.Value -> IO a
75+
exitWithResponse : Encode.Value -> Task Never a
7476
exitWithResponse value =
7577
Impure.task "exitWithResponse" [] (Impure.JsonBody value) Impure.Crash
7678

src/Browser/Make.elm

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import Builder.Elm.Details as Details
1717
import Builder.Generate as Generate
1818
import Builder.Reporting as Reporting
1919
import Builder.Reporting.Exit as Exit
20-
import Builder.Reporting.Task as Task
2120
import Builder.Stuff as Stuff
2221
import Compiler.AST.Optimized as Opt
2322
import Compiler.Data.NonEmptyList as NE
2423
import Compiler.Elm.ModuleName as ModuleName
2524
import Compiler.Generate.Html as Html
2625
import Maybe.Extra as Maybe
27-
import System.IO as IO exposing (IO)
26+
import Task exposing (Task)
2827
import Terminal.Terminal.Internal exposing (Parser(..))
2928
import Utils.Crash exposing (crash)
3029
import Utils.Main as Utils exposing (FilePath)
30+
import Utils.Task.Extra as Task
3131

3232

3333

@@ -52,25 +52,21 @@ type ReportType
5252
-- RUN
5353

5454

55-
type alias Task a =
56-
Task.Task Exit.Make a
57-
58-
59-
run : String -> Flags -> IO (Result Exit.Make String)
55+
run : String -> Flags -> Task Never (Result Exit.Make String)
6056
run path flags =
6157
Stuff.findRoot
62-
|> IO.bind
58+
|> Task.bind
6359
(\maybeRoot ->
6460
case maybeRoot of
6561
Just root ->
6662
runHelp root path flags
6763

6864
Nothing ->
69-
IO.pure (Err Exit.MakeNoOutline)
65+
Task.pure (Err Exit.MakeNoOutline)
7066
)
7167

7268

73-
runHelp : String -> String -> Flags -> IO (Result Exit.Make String)
69+
runHelp : String -> String -> Flags -> Task Never (Result Exit.Make String)
7470
runHelp root path (Flags debug optimize withSourceMaps) =
7571
BW.withScope
7672
(\scope ->
@@ -112,7 +108,7 @@ runHelp root path (Flags debug optimize withSourceMaps) =
112108
-- GET INFORMATION
113109

114110

115-
getMode : Bool -> Bool -> Task DesiredMode
111+
getMode : Bool -> Bool -> Task Exit.Make DesiredMode
116112
getMode debug optimize =
117113
case ( debug, optimize ) of
118114
( True, True ) ->
@@ -132,7 +128,7 @@ getMode debug optimize =
132128
-- BUILD PROJECTS
133129

134130

135-
buildPaths : Reporting.Style -> FilePath -> Details.Details -> NE.Nonempty FilePath -> Task Build.Artifacts
131+
buildPaths : Reporting.Style -> FilePath -> Details.Details -> NE.Nonempty FilePath -> Task Exit.Make Build.Artifacts
136132
buildPaths style root details paths =
137133
Task.eio Exit.MakeCannotBuild <|
138134
Build.fromPaths style root details paths
@@ -182,7 +178,7 @@ type DesiredMode
182178
| Prod
183179

184180

185-
toBuilder : Bool -> Int -> FilePath -> Details.Details -> DesiredMode -> Build.Artifacts -> Task String
181+
toBuilder : Bool -> Int -> FilePath -> Details.Details -> DesiredMode -> Build.Artifacts -> Task Exit.Make String
186182
toBuilder withSourceMaps leadingLines root details desiredMode artifacts =
187183
Task.mapError Exit.MakeBadGenerate <|
188184
case desiredMode of
@@ -205,8 +201,8 @@ reportType =
205201
Parser
206202
{ singular = "report type"
207203
, plural = "report types"
208-
, suggest = \_ -> IO.pure [ "json" ]
209-
, examples = \_ -> IO.pure [ "json" ]
204+
, suggest = \_ -> Task.pure [ "json" ]
205+
, examples = \_ -> Task.pure [ "json" ]
210206
}
211207

212208

@@ -224,8 +220,8 @@ output =
224220
Parser
225221
{ singular = "output file"
226222
, plural = "output files"
227-
, suggest = \_ -> IO.pure []
228-
, examples = \_ -> IO.pure [ "elm.js", "index.html", "/dev/null" ]
223+
, suggest = \_ -> Task.pure []
224+
, examples = \_ -> Task.pure [ "elm.js", "index.html", "/dev/null" ]
229225
}
230226

231227

@@ -249,8 +245,8 @@ docsFile =
249245
Parser
250246
{ singular = "json file"
251247
, plural = "json files"
252-
, suggest = \_ -> IO.pure []
253-
, examples = \_ -> IO.pure [ "docs.json", "documentation.json" ]
248+
, suggest = \_ -> Task.pure []
249+
, examples = \_ -> Task.pure [ "docs.json", "documentation.json" ]
254250
}
255251

256252

src/Browser/Uninstall.elm

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,30 @@ import Builder.Elm.Details as Details
66
import Builder.Elm.Outline as Outline
77
import Builder.Reporting as Reporting
88
import Builder.Reporting.Exit as Exit
9-
import Builder.Reporting.Task as Task
109
import Builder.Stuff as Stuff
1110
import Compiler.Elm.Constraint as C
1211
import Compiler.Elm.Package as Pkg
1312
import Compiler.Elm.Version as V
1413
import Data.Map as Dict exposing (Dict)
15-
import System.IO as IO exposing (IO)
14+
import System.IO as IO
15+
import Task exposing (Task)
1616
import Utils.Main exposing (FilePath)
17+
import Utils.Task.Extra as Task
1718

1819

1920

2021
-- RUN
2122

2223

23-
run : Pkg.Name -> IO ()
24+
run : Pkg.Name -> Task Never ()
2425
run pkg =
2526
Reporting.attempt Exit.uninstallToReport
2627
(Stuff.findRoot
27-
|> IO.bind
28+
|> Task.bind
2829
(\maybeRoot ->
2930
case maybeRoot of
3031
Nothing ->
31-
IO.pure (Err Exit.UninstallNoOutline)
32+
Task.pure (Err Exit.UninstallNoOutline)
3233

3334
Just root ->
3435
Task.run
@@ -62,11 +63,7 @@ type Changes vsn
6263
| Changes Outline.Outline
6364

6465

65-
type alias Task a =
66-
Task.Task Exit.Uninstall a
67-
68-
69-
attemptChanges : String -> Solver.Env -> Outline.Outline -> Changes a -> Task ()
66+
attemptChanges : String -> Solver.Env -> Outline.Outline -> Changes a -> Task Exit.Uninstall ()
7067
attemptChanges root env oldOutline changes =
7168
case changes of
7269
AlreadyNotPresent ->
@@ -76,23 +73,23 @@ attemptChanges root env oldOutline changes =
7673
attemptChangesHelp root env oldOutline newOutline
7774

7875

79-
attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task ()
76+
attemptChangesHelp : FilePath -> Solver.Env -> Outline.Outline -> Outline.Outline -> Task Exit.Uninstall ()
8077
attemptChangesHelp root env oldOutline newOutline =
8178
Task.eio Exit.UninstallBadDetails <|
8279
BW.withScope
8380
(\scope ->
8481
Outline.write root newOutline
85-
|> IO.bind (\_ -> Details.verifyInstall scope root env newOutline)
86-
|> IO.bind
82+
|> Task.bind (\_ -> Details.verifyInstall scope root env newOutline)
83+
|> Task.bind
8784
(\result ->
8885
case result of
8986
Err exit ->
9087
Outline.write root oldOutline
91-
|> IO.fmap (\_ -> Err exit)
88+
|> Task.fmap (\_ -> Err exit)
9289

9390
Ok () ->
9491
IO.putStrLn "Success!"
95-
|> IO.fmap (\_ -> Ok ())
92+
|> Task.fmap (\_ -> Ok ())
9693
)
9794
)
9895

@@ -101,7 +98,7 @@ attemptChangesHelp root env oldOutline newOutline =
10198
-- MAKE APP PLAN
10299

103100

104-
makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task (Changes V.Version)
101+
makeAppPlan : Solver.Env -> Pkg.Name -> Outline.AppOutline -> Task Exit.Uninstall (Changes V.Version)
105102
makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline _ _ direct _ testDirect _) as outline) =
106103
case Dict.get identity pkg (Dict.union direct testDirect) of
107104
Just _ ->
@@ -130,7 +127,7 @@ makeAppPlan (Solver.Env cache _ connection registry) pkg ((Outline.AppOutline _
130127
-- MAKE PACKAGE PLAN
131128

132129

133-
makePkgPlan : Pkg.Name -> Outline.PkgOutline -> Task (Changes C.Constraint)
130+
makePkgPlan : Pkg.Name -> Outline.PkgOutline -> Task Exit.Uninstall (Changes C.Constraint)
134131
makePkgPlan pkg (Outline.PkgOutline name summary license version exposed deps test elmVersion) =
135132
let
136133
old : Dict ( String, String ) Pkg.Name C.Constraint

0 commit comments

Comments
 (0)