sparsec

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

commit 0ef3f55b8e3aaf39074c713feedc96a04b48a43c
parent 05ba9e85076778176007539d54f84623b476e128
Author: Robert Russell <robert@rr3.xyz>
Date:   Sun, 14 Dec 2025 12:35:44 -0800

Use standard field selectors

Diffstat:
MSparsec.hs | 8++++----
Mpackage.yaml | 3---
2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Sparsec.hs b/Sparsec.hs @@ -175,7 +175,7 @@ runeIsNum16 = runeElim False charIsNum16 -- characters seen so far), and column (number of characters into the current -- row). All three of these quantities are 0-based. The column tracking is -- somewhat stupid in that it treats each Unicode codepoint as one column. -data Loc = Loc {byte :: Int, row :: Int, col :: Int} deriving (Eq) +data Loc = Loc {locByte :: Int, locRow :: Int, locCol :: Int} deriving (Eq) locZero :: Loc locZero = Loc 0 0 0 @@ -348,7 +348,7 @@ bytesOf p = do (input, beg) <- save a <- p end <- getLoc - pure (a, BS.take (end.byte - beg.byte) input) + pure (a, BS.take (locByte end - locByte beg) input) -- | Convert a failure into an error. -- @@ -428,8 +428,8 @@ nextRune = toRune . UTF8.decode =<< read write . BS.drop w =<< read loc <- getLoc putLoc case c of - '\n' -> loc{byte = loc.byte + w, row = loc.row + 1, col = 0} - _ -> loc{byte = loc.byte + w, col = loc.col + 1} + '\n' -> Loc (locByte loc + w) (locRow loc + 1) 0 + _ -> Loc (locByte loc + w) (locRow loc) (locCol loc + 1) nextChar :: (Utf8Error e, Monad m) => ParseT e m Char nextChar = diff --git a/package.yaml b/package.yaml @@ -13,10 +13,7 @@ language: GHC2024 default-extensions: - BlockArguments - - DuplicateRecordFields - MultiWayIf - - NoFieldSelectors - - OverloadedRecordDot - OverloadedStrings - UndecidableInstances