commit 188f7fc5e2ae60020080c02c95b48e7e0f49573b
parent 2adfe1e78c53e130e138f0d44f894d5a0edfad46
Author: Robert Russell <robert@rr3.xyz>
Date: Tue, 27 Aug 2024 00:31:20 -0700
Pick more reasonable names
Diffstat:
| M | Sparsec.hs | | | 36 | ++++++++++++++++++------------------ |
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/Sparsec.hs b/Sparsec.hs
@@ -281,47 +281,47 @@ nextChar = nextRune >>= \case
RuneEof -> fail
RuneChar c -> pure c
-oneRuneM :: (Utf8Error e, Monad m) => (Rune -> m Bool) -> ParseT e m Rune
-oneRuneM want = do
+runeIfM :: (Utf8Error e, Monad m) => (Rune -> m Bool) -> ParseT e m Rune
+runeIfM want = do
r <- nextRune
(lift $ want r) >>= guard
pure r
-oneRune :: (Utf8Error e, Monad m) => (Rune -> Bool) -> ParseT e m Rune
-oneRune want = oneRuneM (pure . want)
+runeIf :: (Utf8Error e, Monad m) => (Rune -> Bool) -> ParseT e m Rune
+runeIf want = runeIfM (pure . want)
-oneCharM :: (Utf8Error e, Monad m) => (Char -> m Bool) -> ParseT e m Char
-oneCharM want = do
+charIfM :: (Utf8Error e, Monad m) => (Char -> m Bool) -> ParseT e m Char
+charIfM want = do
c <- nextChar
(lift $ want c) >>= guard
pure c
-oneChar :: (Utf8Error e, Monad m) => (Char -> Bool) -> ParseT e m Char
-oneChar want = oneCharM (pure . want)
+charIf :: (Utf8Error e, Monad m) => (Char -> Bool) -> ParseT e m Char
+charIf want = charIfM (pure . want)
-manyRuneM :: (Utf8Error e, Monad m) => (Rune -> m Bool) -> ParseT e m ByteString
-manyRuneM want =
+runeWhileM :: (Utf8Error e, Monad m) => (Rune -> m Bool) -> ParseT e m ByteString
+runeWhileM want =
fst <$> lexM () \((), r) ->
want r >>= \case
False -> pure $ LexRejectEmit ()
True -> pure $ LexAcceptCont ()
-manyRune :: (Utf8Error e, Monad m) => (Rune -> Bool) -> ParseT e m ByteString
-manyRune want = manyRuneM (pure . want)
+runeWhile :: (Utf8Error e, Monad m) => (Rune -> Bool) -> ParseT e m ByteString
+runeWhile want = runeWhileM (pure . want)
-manyCharM :: (Utf8Error e, Monad m) => (Char -> m Bool) -> ParseT e m ByteString
-manyCharM want = manyRuneM \case
+charWhileM :: (Utf8Error e, Monad m) => (Char -> m Bool) -> ParseT e m ByteString
+charWhileM want = runeWhileM \case
RuneEof -> pure False
RuneChar c -> want c
-manyChar :: (Utf8Error e, Monad m) => (Char -> Bool) -> ParseT e m ByteString
-manyChar want = manyCharM (pure . want)
+charWhile :: (Utf8Error e, Monad m) => (Char -> Bool) -> ParseT e m ByteString
+charWhile want = charWhileM (pure . want)
rune :: (Utf8Error e, Monad m) => Rune -> ParseT e m ()
-rune r = oneRune (== r) *> pure ()
+rune r = runeIf (== r) *> pure ()
char :: (Utf8Error e, Monad m) => Char -> ParseT e m ()
-char c = oneChar (== c) *> pure ()
+char c = charIf (== c) *> pure ()
string :: (Utf8Error e, Monad m) => String -> ParseT e m ()
string = traverse_ char