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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/codegen/elm-pages-codegen.js +4 -7
  3. package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  4. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  5. package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  6. package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
  7. package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
  8. package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
  9. package/generator/src/compatibility-key.js +1 -1
  10. package/generator/src/error-formatter.js +7 -3
  11. package/generator/src/render.js +8 -17
  12. package/generator/src/request-cache.js +34 -4
  13. package/generator/static-code/hmr.js +16 -2
  14. package/package.json +1 -1
  15. package/src/ApiRoute.elm +1 -4
  16. package/src/BackendTask/Env.elm +10 -8
  17. package/src/BackendTask/File.elm +10 -10
  18. package/src/BackendTask/Glob.elm +2 -2
  19. package/src/BackendTask/Http.elm +49 -13
  20. package/src/BackendTask/Port.elm +50 -46
  21. package/src/BackendTask.elm +5 -5
  22. package/src/Exception.elm +70 -12
  23. package/src/Form.elm +3 -2
  24. package/src/Pages/Generate.elm +299 -102
  25. package/src/Pages/Internal/Platform/Cli.elm +17 -37
  26. package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
  27. package/src/Pages/Internal/Platform/GeneratorApplication.elm +17 -41
  28. package/src/Pages/Internal/Platform/StaticResponses.elm +11 -25
  29. package/src/Pages/Script.elm +2 -2
  30. package/src/Pages/StaticHttpRequest.elm +1 -23
  31. package/src/Server/Request.elm +3 -2
  32. package/src/MultiDict.elm +0 -49
  33. package/src/PairingHeap.elm +0 -137
  34. package/src/Parser/Extra/String.elm +0 -33
  35. package/src/Parser/Extra.elm +0 -69
  36. package/src/ProgramTest/ComplexQuery.elm +0 -360
  37. package/src/ProgramTest/EffectSimulation.elm +0 -122
  38. package/src/ProgramTest/Failure.elm +0 -367
  39. package/src/ProgramTest/HtmlHighlighter.elm +0 -116
  40. package/src/ProgramTest/HtmlParserHacks.elm +0 -58
  41. package/src/ProgramTest/HtmlRenderer.elm +0 -73
  42. package/src/ProgramTest/Program.elm +0 -30
  43. package/src/ProgramTest/StringLines.elm +0 -26
  44. package/src/ProgramTest/TestHtmlHacks.elm +0 -132
  45. package/src/ProgramTest/TestHtmlParser.elm +0 -201
  46. package/src/ProgramTest.elm +0 -2339
  47. package/src/Query/Extra.elm +0 -55
  48. package/src/SimulatedEffect/Cmd.elm +0 -69
  49. package/src/SimulatedEffect/Http.elm +0 -330
  50. package/src/SimulatedEffect/Navigation.elm +0 -69
  51. package/src/SimulatedEffect/Ports.elm +0 -62
  52. package/src/SimulatedEffect/Process.elm +0 -24
  53. package/src/SimulatedEffect/Sub.elm +0 -48
  54. package/src/SimulatedEffect/Task.elm +0 -252
  55. package/src/SimulatedEffect/Time.elm +0 -25
  56. package/src/SimulatedEffect.elm +0 -42
  57. package/src/String/Extra.elm +0 -6
  58. package/src/Test/Http.elm +0 -145
  59. package/src/TestResult.elm +0 -35
  60. package/src/TestState.elm +0 -305
  61. package/src/Url/Extra.elm +0 -100
  62. package/src/Vendored/Diff.elm +0 -321
  63. package/src/Vendored/Failure.elm +0 -217
  64. package/src/Vendored/FormatMonochrome.elm +0 -44
  65. 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
- let
794
- updatedModel : Model route
795
- updatedModel =
796
- model
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
- let
825
- updatedModel : Model route
826
- updatedModel =
827
- { model
828
- | staticResponses = updatedStaticResponsesModel
829
- }
830
- in
831
- if List.isEmpty httpRequests then
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
@@ -3,4 +3,4 @@ module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKe
3
3
 
4
4
  currentCompatibilityKey : Int
5
5
  currentCompatibilityKey =
6
- 4
6
+ 5
@@ -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
- let
329
- updatedModel : Model
330
- updatedModel =
331
- model
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
- let
360
- updatedModel : Model
361
- updatedModel =
362
- { model
363
- | allRawResponses = Encode.object []
364
- , staticResponses = updatedStaticResponsesModel
365
- }
366
- in
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(..), batchUpdate, empty, nextStep, renderApiRequest)
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 (Catchable(..), Throwable)
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
- { model
48
- | staticResponses : BackendTask Throwable a
49
- , errors : List BuildError
50
- , allRawResponses : RequestsAndPending
51
- }
32
+ RequestsAndPending
33
+ -> BackendTask Throwable a
34
+ ->
35
+ { model
36
+ | errors : List BuildError
37
+ }
52
38
  -> NextStep route a
53
- nextStep ({ allRawResponses, errors } as model) =
39
+ nextStep allRawResponses staticResponses { errors } =
54
40
  let
55
41
  staticRequestsStatus : StaticHttpRequest.Status Throwable a
56
42
  staticRequestsStatus =
57
43
  allRawResponses
58
- |> StaticHttpRequest.cacheRequestResolution model.staticResponses
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 (Catchable () buildError)) ->
114
+ Just (Err (Exception () buildError)) ->
129
115
  FinishedWithErrors
130
116
  [ { title = buildError.title |> String.toUpper
131
117
  , path = "" -- TODO include path here
@@ -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 (Catchable, Throwable)
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 (Catchable Error) ()
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
- cacheRequestResolutionHelp urlList rawResponses (lookupFn Nothing rawResponses)
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
@@ -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 error (Validation.Validation error combined kind constraints))
885
- -> Parser (BackendTask error (Result (Form.Response error) ( Form.Response error, combined )))
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)
@@ -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 /= '"'
@@ -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