sparsec

simple Haskell parser combinator library
git clone git://git.rr3.xyz/sparsec
Log | Files | Refs | README | LICENSE

commit 03a59e42504d4ac54b0dcedb60d04a8bb7e941e3
parent 06dc23fb745d06ba346bdb643fc43358a9d9a3b3
Author: Robert Russell <robert@rr3.xyz>
Date:   Sun, 14 Dec 2025 11:34:48 -0800

Rename qualified import

Diffstat:
MSparsec.hs | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Sparsec.hs b/Sparsec.hs @@ -96,7 +96,7 @@ import Control.Monad.Identity import Control.Monad.Reader import Control.Monad.State import Data.ByteString (ByteString) -import Data.ByteString qualified as ByteString +import Data.ByteString qualified as BS import Data.ByteString.UTF8 qualified as UTF8 import Data.Char import Data.Foldable @@ -209,13 +209,13 @@ instance (Show e, Show a) => Show (Result e a) where Failure -> "failure" Error e -> "error: " ++ show e Ok a rest _ -> - if ByteString.null rest + if BS.null rest then printf "ok: %s" (show a) else printf "ok (%d bytes remaining): %s" - (ByteString.length rest) + (BS.length rest) (show a) instance Functor (Result e) where @@ -362,7 +362,7 @@ p `catch` h = ParseT \input loc -> -- General combinators eof :: (Monad m) => ParseT e m () -eof = guard . ByteString.null =<< read +eof = guard . BS.null =<< read -- | Run a parser without changing the parser state. lookahead :: (Monad m) => ParseT e m a -> ParseT e m a @@ -384,7 +384,7 @@ bytesOf p = do (input, beg) <- save a <- p end <- getLoc - pure (a, ByteString.take (end.byte - beg.byte) input) + pure (a, BS.take (end.byte - beg.byte) input) -- | Convert a failure into an error. -- @@ -461,7 +461,7 @@ nextRune = toRune . UTF8.decode =<< read updateState :: Char -> Int -> ParseT e m () updateState c w = do - write . ByteString.drop w =<< read + write . BS.drop w =<< read loc <- getLoc putLoc case c of '\n' -> loc{byte = loc.byte + w, row = loc.row + 1, col = 0}