@@ -21,7 +21,7 @@ module Parser exposing
2121@docs int, float, number, symbol, keyword, variable, end
2222
2323# Pipelines
24- @docs succeed, (|=), (|.), lazy, andThen, problem
24+ @docs succeed, (|=), (|.), keep, skip, lazy, andThen, problem
2525
2626# Branches
2727@docs oneOf, map, backtrackable, commit, token
@@ -233,22 +233,36 @@ succeed =
233233 A.succeed
234234
235235
236+ {-| Deprecated. Please look at [keep](#keep) instead.
237+ -}
238+ keeper : Parser (a -> b) -> Parser a -> Parser b
239+ keeper =
240+ (|=)
241+
242+
243+ {-| Deprecated. Please look at [skip](#skip) instead.
244+ -}
245+ ignorer : Parser keep -> Parser ignore -> Parser keep
246+ ignorer =
247+ (|.)
248+
249+
236250{-| **Keep** values in a parser pipeline. For example, we could say:
237251
238252 type alias Point = { x : Float, y : Float }
239253
240254 point : Parser Point
241255 point =
242256 succeed (\x y -> { x = x, y = y })
243- |. symbol "("
244- |. spaces
245- |= float
246- |. spaces
247- |. symbol ","
248- |. spaces
249- |= float
250- |. spaces
251- |. symbol ")"
257+ |> skip ( symbol "(")
258+ |> skip spaces
259+ |> keep float
260+ |> skip spaces
261+ |> skip ( symbol ",")
262+ |> skip spaces
263+ |> keep float
264+ |> skip spaces
265+ |> skip ( symbol ")")
252266
253267All the parsers in this pipeline will chomp characters and produce values. So
254268`symbol "("` will chomp one paren and produce a `{}` value. Similarly, `float`
@@ -258,9 +272,9 @@ operators just decide whether we give the values to the `Point` function.
258272So in this case, we skip the `{}` from `symbol "("`, we skip the `{}` from
259273`spaces`, we keep the `Float` from `float`, etc.
260274-}
261- keeper : Parser (a -> b) -> Parser a -> Parser b
262- keeper =
263- (|=)
275+ keep : Parser keep -> Parser (keep -> b) -> Parser b
276+ keep =
277+ A.keep
264278
265279
266280{-| **Skip** values in a parser pipeline. For example, maybe we want to parse
@@ -270,8 +284,8 @@ some JavaScript variables:
270284 var =
271285 getChompedString <|
272286 succeed {}
273- |. chompIf isStartChar
274- |. chompWhile isInnerChar
287+ |> skip ( chompIf isStartChar)
288+ |> skip ( chompWhile isInnerChar)
275289
276290 isStartChar : Char -> Bool
277291 isStartChar char =
@@ -286,16 +300,6 @@ some JavaScript variables:
286300value. The `(|.)` operators are saying to still chomp all the characters, but
287301skip the two `{}` values that get produced. No one cares about them.
288302-}
289- ignorer : Parser keep -> Parser ignore -> Parser keep
290- ignorer =
291- (|.)
292-
293-
294- keep : Parser keep -> Parser (keep -> b) -> Parser b
295- keep =
296- A.keep
297-
298-
299303skip : Parser ignore -> Parser kept -> Parser kept
300304skip =
301305 A.skip
0 commit comments