Skip to content

Commit dbd9aae

Browse files
committed
Rename splitMap to consumeWith
1 parent fe25855 commit dbd9aae

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: src/Text/Parsing/Parser/String.purs

+9-9
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module Text.Parsing.Parser.String
3838
, match
3939
, regex
4040
, RegexFlagsRow
41-
, splitMap
41+
, consumeWith
4242
) where
4343

4444
import Prelude hiding (between)
@@ -77,12 +77,12 @@ eof = ParserT
7777

7878
-- | Match the entire rest of the input stream. Always succeeds.
7979
rest :: forall m. ParserT String m String
80-
rest = splitMap \consumed ->
80+
rest = consumeWith \consumed ->
8181
Right { value: consumed, consumed, remainder: "" }
8282

8383
-- | Match the specified string.
8484
string :: forall m. String -> ParserT String m String
85-
string str = splitMap \input ->
85+
string str = consumeWith \input ->
8686
case stripPrefix (Pattern str) input of
8787
Just remainder ->
8888
Right { value: str, consumed: str, remainder }
@@ -141,7 +141,7 @@ char c = satisfy (_ == c) <?> show c
141141

142142
-- | Match a `String` exactly *N* characters long.
143143
takeN :: forall m. Int -> ParserT String m String
144-
takeN n = splitMap \input -> do
144+
takeN n = consumeWith \input -> do
145145
let { before, after } = splitAt n input
146146
if length before == n then
147147
Right { value: before, consumed: before, remainder: after }
@@ -155,7 +155,7 @@ whiteSpace = fst <$> match skipSpaces
155155

156156
-- | Skip whitespace characters and throw them away. Always succeeds.
157157
skipSpaces :: forall m. ParserT String m Unit
158-
skipSpaces = splitMap \input -> do
158+
skipSpaces = consumeWith \input -> do
159159
let consumed = takeWhile isSpace input
160160
let remainder = SCU.drop (SCU.length consumed) input
161161
Right { value: unit, consumed, remainder }
@@ -291,7 +291,7 @@ regex flags pattern =
291291
Left paterr ->
292292
fail $ "Regex pattern error " <> paterr
293293
Right regexobj ->
294-
splitMap \input -> do
294+
consumeWith \input -> do
295295
case NonEmptyArray.head <$> Regex.match regexobj input of
296296
Just (Just consumed) -> do
297297
let remainder = SCU.drop (SCU.length consumed) input
@@ -320,15 +320,15 @@ type RegexFlagsRow =
320320
, unicode :: Boolean
321321
)
322322

323-
-- | Splits the input string while yielding a value.
323+
-- | Consumes a portion of the input string while yielding a value.
324324
-- | * `value` is the value to return.
325325
-- | * `consumed` is the input that was consumed and is used to update the parser position.
326326
-- | * `remainder` is the new input state.
327-
splitMap
327+
consumeWith
328328
:: forall m a
329329
. (String -> Either String { value :: a, consumed :: String, remainder :: String })
330330
-> ParserT String m a
331-
splitMap f = ParserT
331+
consumeWith f = ParserT
332332
( mkFn5 \state1@(ParseState input pos _) _ _ throw done ->
333333
case f input of
334334
Left err ->

0 commit comments

Comments
 (0)