elm-pages 3.0.0-beta.14 → 3.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.js +4 -7
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/src/compatibility-key.js +1 -1
- package/generator/src/error-formatter.js +7 -3
- package/generator/src/render.js +8 -17
- package/generator/src/request-cache.js +34 -4
- package/generator/static-code/hmr.js +16 -2
- package/package.json +1 -1
- package/src/ApiRoute.elm +1 -4
- package/src/BackendTask/Env.elm +10 -8
- package/src/BackendTask/File.elm +10 -10
- package/src/BackendTask/Glob.elm +2 -2
- package/src/BackendTask/Http.elm +49 -13
- package/src/BackendTask/Port.elm +50 -46
- package/src/BackendTask.elm +5 -5
- package/src/Exception.elm +70 -12
- package/src/Form.elm +3 -2
- package/src/Pages/Generate.elm +299 -102
- package/src/Pages/Internal/Platform/Cli.elm +17 -37
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +17 -41
- package/src/Pages/Internal/Platform/StaticResponses.elm +11 -25
- package/src/Pages/Script.elm +2 -2
- package/src/Pages/StaticHttpRequest.elm +1 -23
- package/src/Server/Request.elm +3 -2
- package/src/MultiDict.elm +0 -49
- package/src/PairingHeap.elm +0 -137
- package/src/Parser/Extra/String.elm +0 -33
- package/src/Parser/Extra.elm +0 -69
- package/src/ProgramTest/ComplexQuery.elm +0 -360
- package/src/ProgramTest/EffectSimulation.elm +0 -122
- package/src/ProgramTest/Failure.elm +0 -367
- package/src/ProgramTest/HtmlHighlighter.elm +0 -116
- package/src/ProgramTest/HtmlParserHacks.elm +0 -58
- package/src/ProgramTest/HtmlRenderer.elm +0 -73
- package/src/ProgramTest/Program.elm +0 -30
- package/src/ProgramTest/StringLines.elm +0 -26
- package/src/ProgramTest/TestHtmlHacks.elm +0 -132
- package/src/ProgramTest/TestHtmlParser.elm +0 -201
- package/src/ProgramTest.elm +0 -2339
- package/src/Query/Extra.elm +0 -55
- package/src/SimulatedEffect/Cmd.elm +0 -69
- package/src/SimulatedEffect/Http.elm +0 -330
- package/src/SimulatedEffect/Navigation.elm +0 -69
- package/src/SimulatedEffect/Ports.elm +0 -62
- package/src/SimulatedEffect/Process.elm +0 -24
- package/src/SimulatedEffect/Sub.elm +0 -48
- package/src/SimulatedEffect/Task.elm +0 -252
- package/src/SimulatedEffect/Time.elm +0 -25
- package/src/SimulatedEffect.elm +0 -42
- package/src/String/Extra.elm +0 -6
- package/src/Test/Http.elm +0 -145
- package/src/TestResult.elm +0 -35
- package/src/TestState.elm +0 -305
- package/src/Url/Extra.elm +0 -100
- package/src/Vendored/Diff.elm +0 -321
- package/src/Vendored/Failure.elm +0 -217
- package/src/Vendored/FormatMonochrome.elm +0 -44
- package/src/Vendored/Highlightable.elm +0 -53
|
@@ -53,7 +53,6 @@ currentCompatibilityKey =
|
|
|
53
53
|
type alias Model route =
|
|
54
54
|
{ staticResponses : BackendTask Throwable Effect
|
|
55
55
|
, errors : List BuildError
|
|
56
|
-
, allRawResponses : RequestsAndPending
|
|
57
56
|
, maybeRequestJson : RenderRequest route
|
|
58
57
|
, isDevServer : Bool
|
|
59
58
|
}
|
|
@@ -310,7 +309,6 @@ init site renderRequest config flags =
|
|
|
310
309
|
, path = ""
|
|
311
310
|
}
|
|
312
311
|
]
|
|
313
|
-
, allRawResponses = Json.Encode.object []
|
|
314
312
|
, maybeRequestJson = renderRequest
|
|
315
313
|
, isDevServer = False
|
|
316
314
|
}
|
|
@@ -325,7 +323,6 @@ init site renderRequest config flags =
|
|
|
325
323
|
, path = ""
|
|
326
324
|
}
|
|
327
325
|
]
|
|
328
|
-
, allRawResponses = Json.Encode.object []
|
|
329
326
|
, maybeRequestJson = renderRequest
|
|
330
327
|
, isDevServer = False
|
|
331
328
|
}
|
|
@@ -763,12 +760,11 @@ initLegacy site ((RenderRequest.SinglePage includeHtml singleRequest _) as rende
|
|
|
763
760
|
initialModel =
|
|
764
761
|
{ staticResponses = staticResponsesNew
|
|
765
762
|
, errors = []
|
|
766
|
-
, allRawResponses = Json.Encode.object []
|
|
767
763
|
, maybeRequestJson = renderRequest
|
|
768
764
|
, isDevServer = isDevServer
|
|
769
765
|
}
|
|
770
766
|
in
|
|
771
|
-
StaticResponses.nextStep initialModel
|
|
767
|
+
StaticResponses.nextStep (Json.Encode.object []) initialModel.staticResponses initialModel
|
|
772
768
|
|> nextStepToEffect
|
|
773
769
|
initialModel
|
|
774
770
|
|
|
@@ -777,7 +773,8 @@ updateAndSendPortIfDone :
|
|
|
777
773
|
Model route
|
|
778
774
|
-> ( Model route, Effect )
|
|
779
775
|
updateAndSendPortIfDone model =
|
|
780
|
-
StaticResponses.nextStep
|
|
776
|
+
StaticResponses.nextStep (Json.Encode.object [])
|
|
777
|
+
model.staticResponses
|
|
781
778
|
model
|
|
782
779
|
|> nextStepToEffect model
|
|
783
780
|
|
|
@@ -790,15 +787,10 @@ update :
|
|
|
790
787
|
update msg model =
|
|
791
788
|
case msg of
|
|
792
789
|
GotDataBatch batch ->
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|> StaticResponses.batchUpdate batch
|
|
798
|
-
in
|
|
799
|
-
StaticResponses.nextStep
|
|
800
|
-
updatedModel
|
|
801
|
-
|> nextStepToEffect updatedModel
|
|
790
|
+
StaticResponses.nextStep batch
|
|
791
|
+
model.staticResponses
|
|
792
|
+
model
|
|
793
|
+
|> nextStepToEffect model
|
|
802
794
|
|
|
803
795
|
GotBuildError buildError ->
|
|
804
796
|
let
|
|
@@ -809,7 +801,8 @@ update msg model =
|
|
|
809
801
|
buildError :: model.errors
|
|
810
802
|
}
|
|
811
803
|
in
|
|
812
|
-
StaticResponses.nextStep
|
|
804
|
+
StaticResponses.nextStep (Json.Encode.object [])
|
|
805
|
+
updatedModel.staticResponses
|
|
813
806
|
updatedModel
|
|
814
807
|
|> nextStepToEffect updatedModel
|
|
815
808
|
|
|
@@ -821,27 +814,14 @@ nextStepToEffect :
|
|
|
821
814
|
nextStepToEffect model nextStep =
|
|
822
815
|
case nextStep of
|
|
823
816
|
StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
nextStepToEffect
|
|
833
|
-
updatedModel
|
|
834
|
-
(StaticResponses.nextStep
|
|
835
|
-
updatedModel
|
|
836
|
-
)
|
|
837
|
-
|
|
838
|
-
else
|
|
839
|
-
( updatedModel
|
|
840
|
-
, (httpRequests
|
|
841
|
-
|> List.map Effect.FetchHttp
|
|
842
|
-
)
|
|
843
|
-
|> Effect.Batch
|
|
844
|
-
)
|
|
817
|
+
( { model
|
|
818
|
+
| staticResponses = updatedStaticResponsesModel
|
|
819
|
+
}
|
|
820
|
+
, (httpRequests
|
|
821
|
+
|> List.map Effect.FetchHttp
|
|
822
|
+
)
|
|
823
|
+
|> Effect.Batch
|
|
824
|
+
)
|
|
845
825
|
|
|
846
826
|
StaticResponses.FinishedWithErrors errors ->
|
|
847
827
|
( model
|
|
@@ -22,7 +22,6 @@ import Pages.Internal.Platform.StaticResponses as StaticResponses
|
|
|
22
22
|
import Pages.Internal.Platform.ToJsPayload as ToJsPayload
|
|
23
23
|
import Pages.Internal.Script
|
|
24
24
|
import Pages.StaticHttp.Request
|
|
25
|
-
import RequestsAndPending exposing (RequestsAndPending)
|
|
26
25
|
import TerminalText as Terminal
|
|
27
26
|
|
|
28
27
|
|
|
@@ -36,8 +35,6 @@ type alias Flags =
|
|
|
36
35
|
type alias Model =
|
|
37
36
|
{ staticResponses : BackendTask Throwable ()
|
|
38
37
|
, errors : List BuildError
|
|
39
|
-
, allRawResponses : RequestsAndPending
|
|
40
|
-
, done : Bool
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
|
|
@@ -281,8 +278,6 @@ init execute flags =
|
|
|
281
278
|
, path = ""
|
|
282
279
|
}
|
|
283
280
|
]
|
|
284
|
-
, allRawResponses = Encode.object []
|
|
285
|
-
, done = False
|
|
286
281
|
}
|
|
287
282
|
|
|
288
283
|
|
|
@@ -299,11 +294,9 @@ initLegacy execute =
|
|
|
299
294
|
initialModel =
|
|
300
295
|
{ staticResponses = staticResponses
|
|
301
296
|
, errors = []
|
|
302
|
-
, allRawResponses = Encode.object []
|
|
303
|
-
, done = False
|
|
304
297
|
}
|
|
305
298
|
in
|
|
306
|
-
StaticResponses.nextStep initialModel
|
|
299
|
+
StaticResponses.nextStep (Encode.object []) initialModel.staticResponses initialModel
|
|
307
300
|
|> nextStepToEffect
|
|
308
301
|
initialModel
|
|
309
302
|
|
|
@@ -312,7 +305,8 @@ updateAndSendPortIfDone :
|
|
|
312
305
|
Model
|
|
313
306
|
-> ( Model, Effect )
|
|
314
307
|
updateAndSendPortIfDone model =
|
|
315
|
-
StaticResponses.nextStep
|
|
308
|
+
StaticResponses.nextStep (Encode.object [])
|
|
309
|
+
model.staticResponses
|
|
316
310
|
model
|
|
317
311
|
|> nextStepToEffect model
|
|
318
312
|
|
|
@@ -325,15 +319,10 @@ update :
|
|
|
325
319
|
update msg model =
|
|
326
320
|
case msg of
|
|
327
321
|
GotDataBatch batch ->
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|> StaticResponses.batchUpdate batch
|
|
333
|
-
in
|
|
334
|
-
StaticResponses.nextStep
|
|
335
|
-
updatedModel
|
|
336
|
-
|> nextStepToEffect updatedModel
|
|
322
|
+
StaticResponses.nextStep batch
|
|
323
|
+
model.staticResponses
|
|
324
|
+
model
|
|
325
|
+
|> nextStepToEffect model
|
|
337
326
|
|
|
338
327
|
GotBuildError buildError ->
|
|
339
328
|
let
|
|
@@ -344,7 +333,8 @@ update msg model =
|
|
|
344
333
|
buildError :: model.errors
|
|
345
334
|
}
|
|
346
335
|
in
|
|
347
|
-
StaticResponses.nextStep
|
|
336
|
+
StaticResponses.nextStep (Encode.object [])
|
|
337
|
+
updatedModel.staticResponses
|
|
348
338
|
updatedModel
|
|
349
339
|
|> nextStepToEffect updatedModel
|
|
350
340
|
|
|
@@ -356,28 +346,14 @@ nextStepToEffect :
|
|
|
356
346
|
nextStepToEffect model nextStep =
|
|
357
347
|
case nextStep of
|
|
358
348
|
StaticResponses.Continue httpRequests updatedStaticResponsesModel ->
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if List.isEmpty httpRequests then
|
|
368
|
-
nextStepToEffect
|
|
369
|
-
updatedModel
|
|
370
|
-
(StaticResponses.nextStep
|
|
371
|
-
updatedModel
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
else
|
|
375
|
-
( updatedModel
|
|
376
|
-
, (httpRequests
|
|
377
|
-
|> List.map Effect.FetchHttp
|
|
378
|
-
)
|
|
379
|
-
|> Effect.Batch
|
|
380
|
-
)
|
|
349
|
+
( { model
|
|
350
|
+
| staticResponses = updatedStaticResponsesModel
|
|
351
|
+
}
|
|
352
|
+
, (httpRequests
|
|
353
|
+
|> List.map Effect.FetchHttp
|
|
354
|
+
)
|
|
355
|
+
|> Effect.Batch
|
|
356
|
+
)
|
|
381
357
|
|
|
382
358
|
StaticResponses.Finish () ->
|
|
383
359
|
( model
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
module Pages.Internal.Platform.StaticResponses exposing (NextStep(..),
|
|
1
|
+
module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, nextStep, renderApiRequest)
|
|
2
2
|
|
|
3
3
|
import BackendTask exposing (BackendTask)
|
|
4
4
|
import BuildError exposing (BuildError)
|
|
5
|
-
import Exception exposing (
|
|
6
|
-
import Json.Decode as Decode
|
|
5
|
+
import Exception exposing (Exception(..), Throwable)
|
|
7
6
|
import List.Extra
|
|
8
7
|
import Pages.StaticHttp.Request as HashRequest
|
|
9
8
|
import Pages.StaticHttpRequest as StaticHttpRequest
|
|
@@ -23,20 +22,6 @@ renderApiRequest request =
|
|
|
23
22
|
request
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
batchUpdate :
|
|
27
|
-
Decode.Value
|
|
28
|
-
->
|
|
29
|
-
{ model
|
|
30
|
-
| allRawResponses : Decode.Value
|
|
31
|
-
}
|
|
32
|
-
->
|
|
33
|
-
{ model
|
|
34
|
-
| allRawResponses : Decode.Value
|
|
35
|
-
}
|
|
36
|
-
batchUpdate newEntries model =
|
|
37
|
-
{ model | allRawResponses = newEntries }
|
|
38
|
-
|
|
39
|
-
|
|
40
25
|
type NextStep route value
|
|
41
26
|
= Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest Throwable value)
|
|
42
27
|
| Finish value
|
|
@@ -44,18 +29,19 @@ type NextStep route value
|
|
|
44
29
|
|
|
45
30
|
|
|
46
31
|
nextStep :
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
RequestsAndPending
|
|
33
|
+
-> BackendTask Throwable a
|
|
34
|
+
->
|
|
35
|
+
{ model
|
|
36
|
+
| errors : List BuildError
|
|
37
|
+
}
|
|
52
38
|
-> NextStep route a
|
|
53
|
-
nextStep
|
|
39
|
+
nextStep allRawResponses staticResponses { errors } =
|
|
54
40
|
let
|
|
55
41
|
staticRequestsStatus : StaticHttpRequest.Status Throwable a
|
|
56
42
|
staticRequestsStatus =
|
|
57
43
|
allRawResponses
|
|
58
|
-
|> StaticHttpRequest.cacheRequestResolution
|
|
44
|
+
|> StaticHttpRequest.cacheRequestResolution staticResponses
|
|
59
45
|
|
|
60
46
|
( ( pendingRequests, completedValue ), urlsToPerform, progressedBackendTask ) =
|
|
61
47
|
case staticRequestsStatus of
|
|
@@ -125,7 +111,7 @@ nextStep ({ allRawResponses, errors } as model) =
|
|
|
125
111
|
Just (Ok completed) ->
|
|
126
112
|
Finish completed
|
|
127
113
|
|
|
128
|
-
Just (Err (
|
|
114
|
+
Just (Err (Exception () buildError)) ->
|
|
129
115
|
FinishedWithErrors
|
|
130
116
|
[ { title = buildError.title |> String.toUpper
|
|
131
117
|
, path = "" -- TODO include path here
|
package/src/Pages/Script.elm
CHANGED
|
@@ -34,7 +34,7 @@ import BackendTask.Http
|
|
|
34
34
|
import BackendTask.Internal.Request
|
|
35
35
|
import Cli.OptionsParser as OptionsParser
|
|
36
36
|
import Cli.Program as Program
|
|
37
|
-
import Exception exposing (
|
|
37
|
+
import Exception exposing (Exception, Throwable)
|
|
38
38
|
import Json.Decode as Decode
|
|
39
39
|
import Json.Encode as Encode
|
|
40
40
|
import Pages.Internal.Script
|
|
@@ -52,7 +52,7 @@ type Error
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
{-| -}
|
|
55
|
-
writeFile : { path : String, body : String } -> BackendTask (
|
|
55
|
+
writeFile : { path : String, body : String } -> BackendTask (Exception Error) ()
|
|
56
56
|
writeFile { path, body } =
|
|
57
57
|
BackendTask.Internal.Request.request
|
|
58
58
|
{ name = "write-file"
|
|
@@ -65,7 +65,7 @@ cacheRequestResolution request rawResponses =
|
|
|
65
65
|
case request of
|
|
66
66
|
Request urlList lookupFn ->
|
|
67
67
|
if List.isEmpty urlList then
|
|
68
|
-
|
|
68
|
+
cacheRequestResolution (lookupFn Nothing rawResponses) rawResponses
|
|
69
69
|
|
|
70
70
|
else
|
|
71
71
|
Incomplete urlList (Request [] lookupFn)
|
|
@@ -78,25 +78,3 @@ type Status error value
|
|
|
78
78
|
= Incomplete (List Pages.StaticHttp.Request.Request) (RawRequest error value)
|
|
79
79
|
| HasPermanentError Error
|
|
80
80
|
| Complete (Result error value)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
cacheRequestResolutionHelp :
|
|
84
|
-
List Pages.StaticHttp.Request.Request
|
|
85
|
-
-> RequestsAndPending
|
|
86
|
-
-> RawRequest error value
|
|
87
|
-
-> Status error value
|
|
88
|
-
cacheRequestResolutionHelp foundUrls rawResponses request =
|
|
89
|
-
case request of
|
|
90
|
-
Request urlList lookupFn ->
|
|
91
|
-
if (urlList ++ foundUrls) |> List.isEmpty then
|
|
92
|
-
cacheRequestResolutionHelp
|
|
93
|
-
[]
|
|
94
|
-
rawResponses
|
|
95
|
-
(lookupFn Nothing rawResponses)
|
|
96
|
-
|
|
97
|
-
else
|
|
98
|
-
Incomplete (urlList ++ foundUrls)
|
|
99
|
-
(Request [] lookupFn)
|
|
100
|
-
|
|
101
|
-
ApiRoute value ->
|
|
102
|
-
Complete value
|
package/src/Server/Request.elm
CHANGED
|
@@ -89,6 +89,7 @@ module Server.Request exposing
|
|
|
89
89
|
import BackendTask exposing (BackendTask)
|
|
90
90
|
import CookieParser
|
|
91
91
|
import Dict exposing (Dict)
|
|
92
|
+
import Exception exposing (Throwable)
|
|
92
93
|
import Form
|
|
93
94
|
import Form.Validation as Validation
|
|
94
95
|
import FormData
|
|
@@ -881,8 +882,8 @@ fileField_ name =
|
|
|
881
882
|
|
|
882
883
|
{-| -}
|
|
883
884
|
formDataWithServerValidation :
|
|
884
|
-
Form.ServerForms error (BackendTask
|
|
885
|
-
-> Parser (BackendTask
|
|
885
|
+
Form.ServerForms error (BackendTask Throwable (Validation.Validation error combined kind constraints))
|
|
886
|
+
-> Parser (BackendTask Throwable (Result (Form.Response error) ( Form.Response error, combined )))
|
|
886
887
|
formDataWithServerValidation formParsers =
|
|
887
888
|
rawFormData
|
|
888
889
|
|> andThen
|
package/src/MultiDict.elm
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module MultiDict exposing (MultiDict, empty, get, insert, keys, remove, set)
|
|
2
|
-
|
|
3
|
-
import Dict exposing (Dict)
|
|
4
|
-
import List.Extra
|
|
5
|
-
import List.Nonempty as NonEmpty
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type alias NonEmpty a =
|
|
9
|
-
NonEmpty.Nonempty a
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type MultiDict k v
|
|
13
|
-
= MultiDict (Dict k (NonEmpty v))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
empty : MultiDict k v
|
|
17
|
-
empty =
|
|
18
|
-
MultiDict Dict.empty
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
insert : comparable -> v -> MultiDict comparable v -> MultiDict comparable v
|
|
22
|
-
insert key value (MultiDict dict) =
|
|
23
|
-
MultiDict
|
|
24
|
-
(Dict.update key (Maybe.map (NonEmpty.cons value) >> Maybe.withDefault (NonEmpty.fromElement value) >> Just) dict)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get : comparable -> MultiDict comparable v -> List v
|
|
28
|
-
get key (MultiDict dict) =
|
|
29
|
-
Dict.get key dict
|
|
30
|
-
|> Maybe.map NonEmpty.toList
|
|
31
|
-
|> Maybe.withDefault []
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
keys : MultiDict k v -> List k
|
|
35
|
-
keys (MultiDict dict) =
|
|
36
|
-
Dict.toList dict
|
|
37
|
-
|> List.concatMap (\( k, vs ) -> List.repeat (NonEmpty.length vs) k)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
remove : comparable -> v -> MultiDict comparable v -> MultiDict comparable v
|
|
41
|
-
remove key value (MultiDict dict) =
|
|
42
|
-
MultiDict
|
|
43
|
-
(Dict.update key (Maybe.andThen (NonEmpty.toList >> List.Extra.remove value >> NonEmpty.fromList)) dict)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
set : comparable -> List v -> MultiDict comparable v -> MultiDict comparable v
|
|
47
|
-
set key values (MultiDict dict) =
|
|
48
|
-
MultiDict
|
|
49
|
-
(Dict.update key (\_ -> NonEmpty.fromList values) dict)
|
package/src/PairingHeap.elm
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
module PairingHeap exposing
|
|
2
|
-
( PairingHeap, empty
|
|
3
|
-
, insert, merge, findMin, deleteMin
|
|
4
|
-
, fromList, toSortedList
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
{-| This is a simple pairing heap implementation written in Elm usable as a priority queue. This code is
|
|
8
|
-
based heavily on the pseudocode available at [the Wikipedia page](https://en.wikipedia.org/wiki/Pairing_heap).
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Type and Constructor
|
|
12
|
-
|
|
13
|
-
@docs PairingHeap, empty
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Operations
|
|
17
|
-
|
|
18
|
-
@docs insert, merge, findMin, deleteMin
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Convenience functions
|
|
22
|
-
|
|
23
|
-
@docs fromList, toSortedList
|
|
24
|
-
|
|
25
|
-
-}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{-| A `PairingHeap` has comparable keys and values of an arbitrary type.
|
|
29
|
-
-}
|
|
30
|
-
type PairingHeap comparable a
|
|
31
|
-
= Empty
|
|
32
|
-
| Heap comparable a (List (PairingHeap comparable a))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{-| Create an empty PairingHeap.
|
|
36
|
-
-}
|
|
37
|
-
empty : PairingHeap comparable a
|
|
38
|
-
empty =
|
|
39
|
-
Empty
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{-| Find the minimum value in a heap returning Nothing if the heap is empty.
|
|
43
|
-
Complexity: O(1)
|
|
44
|
-
|
|
45
|
-
findMin (fromList [ ( 10, () ), ( 3, () ), ( 8, () ) ]) == Just 3
|
|
46
|
-
|
|
47
|
-
-}
|
|
48
|
-
findMin : PairingHeap comparable a -> Maybe ( comparable, a )
|
|
49
|
-
findMin x =
|
|
50
|
-
case x of
|
|
51
|
-
Empty ->
|
|
52
|
-
Nothing
|
|
53
|
-
|
|
54
|
-
Heap k v _ ->
|
|
55
|
-
Just ( k, v )
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{-| Merges two `PairingHeap`s together into one new heap containing all of the key-value pairs from both inputs.
|
|
59
|
-
Complexity: O(1)
|
|
60
|
-
-}
|
|
61
|
-
merge : PairingHeap comparable a -> PairingHeap comparable a -> PairingHeap comparable a
|
|
62
|
-
merge heap1 heap2 =
|
|
63
|
-
case ( heap1, heap2 ) of
|
|
64
|
-
( Empty, _ ) ->
|
|
65
|
-
heap2
|
|
66
|
-
|
|
67
|
-
( _, Empty ) ->
|
|
68
|
-
heap1
|
|
69
|
-
|
|
70
|
-
( Heap k1 v1 hs1, Heap k2 v2 hs2 ) ->
|
|
71
|
-
if k1 < k2 then
|
|
72
|
-
Heap k1 v1 (heap2 :: hs1)
|
|
73
|
-
|
|
74
|
-
else
|
|
75
|
-
Heap k2 v2 (heap1 :: hs2)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{-| Inserts a new element into a `PairingHeap`.
|
|
79
|
-
Complexity: O(1)
|
|
80
|
-
-}
|
|
81
|
-
insert : comparable -> a -> PairingHeap comparable a -> PairingHeap comparable a
|
|
82
|
-
insert k v heap =
|
|
83
|
-
merge (Heap k v []) heap
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{-| Removes the minimum element from a `PairingHeap` returning a new heap without that element.
|
|
87
|
-
This will return an empty heap if given an empty heap as input.
|
|
88
|
-
Complexity: O(log n)
|
|
89
|
-
-}
|
|
90
|
-
deleteMin : PairingHeap comparable a -> PairingHeap comparable a
|
|
91
|
-
deleteMin heap =
|
|
92
|
-
case heap of
|
|
93
|
-
Empty ->
|
|
94
|
-
Empty
|
|
95
|
-
|
|
96
|
-
Heap k v heaps ->
|
|
97
|
-
mergePairs heaps
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{-| This is an internal function used by deleteMin.
|
|
101
|
-
-}
|
|
102
|
-
mergePairs : List (PairingHeap comparable a) -> PairingHeap comparable a
|
|
103
|
-
mergePairs heaps =
|
|
104
|
-
case heaps of
|
|
105
|
-
[] ->
|
|
106
|
-
Empty
|
|
107
|
-
|
|
108
|
-
x :: [] ->
|
|
109
|
-
x
|
|
110
|
-
|
|
111
|
-
x :: (y :: xs) ->
|
|
112
|
-
merge (merge x y) (mergePairs xs)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-- Extra convenience functions
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{-| This function turns a list of key-value pairs into a `PairingHeap`.
|
|
120
|
-
Complexity: O(n)
|
|
121
|
-
-}
|
|
122
|
-
fromList : List ( comparable, a ) -> PairingHeap comparable a
|
|
123
|
-
fromList =
|
|
124
|
-
List.foldl (\( k, v ) -> insert k v) empty
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{-| This function turns a `PairingHeap` into a sorted list of key-value pairs.
|
|
128
|
-
Complexity: O(n log n)
|
|
129
|
-
-}
|
|
130
|
-
toSortedList : PairingHeap comparable a -> List ( comparable, a )
|
|
131
|
-
toSortedList heap =
|
|
132
|
-
case heap of
|
|
133
|
-
Empty ->
|
|
134
|
-
[]
|
|
135
|
-
|
|
136
|
-
Heap k v _ ->
|
|
137
|
-
( k, v ) :: toSortedList (deleteMin heap)
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module Parser.Extra.String exposing (string)
|
|
2
|
-
|
|
3
|
-
import Parser exposing (..)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
string : Parser String
|
|
7
|
-
string =
|
|
8
|
-
succeed identity
|
|
9
|
-
|. token "\""
|
|
10
|
-
|= loop [] stringHelp
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
stringHelp : List String -> Parser (Step (List String) String)
|
|
14
|
-
stringHelp revChunks =
|
|
15
|
-
oneOf
|
|
16
|
-
[ succeed (\chunk -> Loop (chunk :: revChunks))
|
|
17
|
-
|. token "\\"
|
|
18
|
-
|= oneOf
|
|
19
|
-
[ map (\_ -> "\n") (token "n")
|
|
20
|
-
, map (\_ -> "\t") (token "t")
|
|
21
|
-
, map (\_ -> "\u{000D}") (token "r")
|
|
22
|
-
]
|
|
23
|
-
, token "\""
|
|
24
|
-
|> map (\_ -> Done (String.join "" (List.reverse revChunks)))
|
|
25
|
-
, chompWhile isUninteresting
|
|
26
|
-
|> getChompedString
|
|
27
|
-
|> map (\chunk -> Loop (chunk :: revChunks))
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
isUninteresting : Char -> Bool
|
|
32
|
-
isUninteresting char =
|
|
33
|
-
char /= '\\' && char /= '"'
|
package/src/Parser/Extra.elm
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
module Parser.Extra exposing (deadEndsToString)
|
|
2
|
-
|
|
3
|
-
{-| [No implementation for deadEndsToString · Issue #9 · elm/parser](https://github.com/elm/parser/issues/9)
|
|
4
|
-
-}
|
|
5
|
-
|
|
6
|
-
import Parser exposing (DeadEnd, Problem(..))
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
deadEndsToString : List DeadEnd -> String
|
|
10
|
-
deadEndsToString deadEnds =
|
|
11
|
-
String.join "\n" (List.map deadEndToString deadEnds)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
deadEndToString : DeadEnd -> String
|
|
15
|
-
deadEndToString deadEnd =
|
|
16
|
-
problemToString deadEnd.problem
|
|
17
|
-
++ " at "
|
|
18
|
-
++ deadEndToRowColString deadEnd
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
problemToString : Problem -> String
|
|
22
|
-
problemToString prob =
|
|
23
|
-
case prob of
|
|
24
|
-
Expecting s ->
|
|
25
|
-
"Expecting " ++ s
|
|
26
|
-
|
|
27
|
-
ExpectingInt ->
|
|
28
|
-
"Expecting Int"
|
|
29
|
-
|
|
30
|
-
ExpectingHex ->
|
|
31
|
-
"Expecting Hex"
|
|
32
|
-
|
|
33
|
-
ExpectingOctal ->
|
|
34
|
-
"Expecting Octal"
|
|
35
|
-
|
|
36
|
-
ExpectingBinary ->
|
|
37
|
-
"Expecting Binary"
|
|
38
|
-
|
|
39
|
-
ExpectingFloat ->
|
|
40
|
-
"Expecting Float"
|
|
41
|
-
|
|
42
|
-
ExpectingNumber ->
|
|
43
|
-
"Expecting Number"
|
|
44
|
-
|
|
45
|
-
ExpectingVariable ->
|
|
46
|
-
"Expecting Variable"
|
|
47
|
-
|
|
48
|
-
ExpectingSymbol s ->
|
|
49
|
-
"Expecting Symbol " ++ s
|
|
50
|
-
|
|
51
|
-
ExpectingKeyword s ->
|
|
52
|
-
"Expecting Keyword " ++ s
|
|
53
|
-
|
|
54
|
-
ExpectingEnd ->
|
|
55
|
-
"Expecting End"
|
|
56
|
-
|
|
57
|
-
UnexpectedChar ->
|
|
58
|
-
"Unexpected Char"
|
|
59
|
-
|
|
60
|
-
Problem s ->
|
|
61
|
-
"Problem: " ++ s
|
|
62
|
-
|
|
63
|
-
BadRepeat ->
|
|
64
|
-
"Bad Repeat"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
deadEndToRowColString : DeadEnd -> String
|
|
68
|
-
deadEndToRowColString deadEnd =
|
|
69
|
-
"row " ++ String.fromInt deadEnd.row ++ ", " ++ "col " ++ String.fromInt deadEnd.col
|