incremental-parser 0.5.0.5 → 0.5.1
raw patch · 4 files changed
+111/−17 lines, 4 filesdep +logictdep ~tastydep ~transformersPVP ok
version bump matches the API change (PVP)
Dependencies added: logict
Dependency ranges changed: tasty, transformers
API changes (from Hackage documentation)
Files
- CHANGELOG.md +88/−0
- Test/TestIncrementalParser.hs +5/−4
- incremental-parser.cabal +4/−4
- src/Text/ParserCombinators/Incremental.hs +14/−9
+ CHANGELOG.md view
@@ -0,0 +1,88 @@+# Revision history for incremental-parser++## 0.5.1 -- 2023-12-19++* Replaced the ListT transformer with LogicT+* Bumped dependency bounds+* Fixed some compiler warnings++## 0.5.0.5 -- 2023-04-09++* Allow `monoid-subclasses-1.2` and `rank2classes-1.5`, thanks to felixonmars++## 0.5.0.4 -- 2022-10-03++* Incremented dependency versions.++## 0.5.0.3 -- 2022-03-09++* Allow `checkers-0.6`++## 0.5.0.2 -- 2021-03-07++* Incremented `monoid-subclasses` and `input-parsers` upper bounds++## 0.5.0.1 -- 2020-12-25++* Incremented the `tasty` dependency version bounds++## 0.5 -- 2020-07-18++* Fixed the `take` method implementation+* Added the `DeterministicParsing` instance+* Cleaned up the comments and warnings+* Added the `InputCharParsing` instance+* Added the `InputParsing` instance++## 0.4.0.2 -- 2020-05-10++* Bumped up the upper dependency bound for `tasty`++## 0.4.0.1 -- 2020-03-08++* Relax bound of `rank2classes` to < 1.5, thanks to felixonmars++## 0.4 -- 2020-01-21++* Improved error reporting+* Changed the result type of inspect to report the error message+* Added the missing `Choice` in `ResultStructure` case, eliminated all warnings except `ListT`+* Generalized the `CharParsing` instance+* Added `mapInput` and `mapInput'`+* Preserve the input left after `ResultStructure`+* Generalized `ResultStructure` off `Identity`+* Eta-reduced the `Parser` type synonyms+* Added `ResultStructure` and the record combinator+* Moved the source code into the `src/` directory+* Added instances for `MonoidFix` and `*Parsing` classes++## 0.3.3 -- 2019-10-10++* Updated for `monoid-subclasses-1.0`++## 0.3.2.2 -- 2019-03-30++* Bumped the `checkers` dependency version bound+* Fixed a bug in the ordering of incremental results++## 0.3.2.1 -- 2019-12-03++* Incremented the upper bound for `tasty`++## 0.3.2 -- 2018-10-14++* Added `MonadFail` instance++## 0.3.1.1 -- 2018-05-12++* Incremented the tasty upper bound+* Fixed compilation with GHC 8.2++## 0.3.1 -- 2018-04-26++* Building with GHC-8.4 and `Semigroup`+* Limited the `base` upper bound++## 0.2.5.3 -- 2018-01-09++* Incremented the upper bound for `tasty`
Test/TestIncrementalParser.hs view
@@ -85,13 +85,14 @@ pure x = TestParser (Described "pure ?" (pure x)) TestParser (Described d1 p1) <*> TestParser (Described d2 p2) = TestParser (Described (d1 ++ " <*> " ++ d2) (p1 <*> p2))+ TestParser (Described d1 p1) *> TestParser (Described d2 p2) =+ TestParser (Described (d1 ++ " *> " ++ d2) (p1 >> p2)) instance Monad (TestParser a) where- return x = TestParser (Described "return ?" (return x))+ return = pure TestParser (Described d1 p1) >>= f = TestParser (Described (d1 ++ " >>= ?") (p1 >>= describedParser . f))- TestParser (Described d1 p1) >> TestParser (Described d2 p2) =- TestParser (Described (d1 ++ " >> " ++ d2) (p1 >> p2))+ (>>) = (*>) instance Alternative (Parser a [Bool]) => Alternative (TestParser a) where empty = TestParser (Described "failure" empty)@@ -284,7 +285,7 @@ instance Monoid Bool where mempty = False- mappend = (||)+ mappend = (<>) showBoolFun :: (r -> String) -> ([Bool] -> r) -> String showBoolFun show f = "\\[b]-> if b then " ++ show (f [True]) ++ " else " ++ show (f [False])
incremental-parser.cabal view
@@ -1,5 +1,5 @@ Name: incremental-parser-Version: 0.5.0.5+Version: 0.5.1 Cabal-Version: >= 1.10 Build-Type: Simple Synopsis: Generic parser library capable of providing partial results from partial input.@@ -18,7 +18,7 @@ Author: Mario Blazevic Maintainer: blamario@yahoo.com Homepage: https://github.com/blamario/incremental-parser-Extra-Source-Files: Benchmarks/airports.dat, README.md+Extra-Source-Files: Benchmarks/airports.dat, README.md, CHANGELOG.md Source-repository head type: git@@ -29,7 +29,7 @@ Exposed-Modules: Text.ParserCombinators.Incremental, Text.ParserCombinators.Incremental.LeftBiasedLocal, Text.ParserCombinators.Incremental.Symmetric, Control.Applicative.Monoid- Build-Depends: base >= 4.9 && < 5, transformers >= 0.5 && < 0.6, parsers < 0.13,+ Build-Depends: base >= 4.9 && < 5, transformers >= 0.5 && < 0.7, logict >= 0.6 && < 0.9, parsers < 0.13, monoid-subclasses < 1.3, rank2classes >= 1.0 && < 1.6, input-parsers < 0.4 ghc-options: -Wall if impl(ghc >= 7.0.0)@@ -41,7 +41,7 @@ Default-Language: Haskell2010 Build-Depends: base < 5, incremental-parser, monoid-subclasses < 1.3, QuickCheck >= 2 && < 3, checkers >= 0.3.2 && < 0.7,- tasty >= 0.7 && < 1.5, tasty-quickcheck >= 0.7 && < 1.0+ tasty >= 0.7 && < 1.6, tasty-quickcheck >= 0.7 && < 1.0 Main-is: Test/TestIncrementalParser.hs benchmark CSV
src/Text/ParserCombinators/Incremental.hs view
@@ -14,7 +14,7 @@ -- -- Implementation is based on Brzozowski derivatives. -{-# LANGUAGE FlexibleContexts, FlexibleInstances, GADTs, RankNTypes, TypeFamilies, UndecidableInstances #-}+{-# LANGUAGE FlexibleContexts, FlexibleInstances, GADTs, RankNTypes, ScopedTypeVariables, TypeFamilies, UndecidableInstances #-} module Text.ParserCombinators.Incremental ( -- * The Parser type@@ -39,7 +39,7 @@ import Control.Applicative.Monoid(MonoidApplicative(..), MonoidAlternative(..)) import Control.Monad.Fail (MonadFail(fail)) import Control.Monad.Fix (MonadFix(mfix))-import Control.Monad.Trans.List (ListT(ListT), runListT)+import Control.Monad.Logic (LogicT(LogicT), observeAllT) import Control.Monad.Trans.State.Strict (State, runState, state, StateT(StateT, runStateT)) import Data.Foldable (fold) import Data.Maybe (fromMaybe)@@ -99,16 +99,21 @@ feedEof (ResultPart r e _) = prepend r (feedEof e) feedEof (Choice p1 p2) = feedEof p1 <||> feedEof p2 feedEof (Delay e _) = feedEof e-feedEof (ResultStructure s r) = either Failure collect (runListT $ runStateT (Rank2.traverse feedEofMaybe r) Nothing)+feedEof (ResultStructure s r) = either Failure collect (observeAllT $ runStateT (Rank2.traverse feedEofMaybe r) Nothing) where collect = foldr1 Choice . map result result (r', s') = Result (fold s' <> fold s) r' -feedEofMaybe :: (Applicative m, Monoid s) => Parser t s r -> StateT (Maybe s) (ListT (Either String)) (m r)-feedEofMaybe p = StateT (\s-> ListT $ case feedEof (maybe id feed s p)- of Failure msg -> Left msg- p' -> Right (map wrap $ completeResults p'))- where wrap (r, s) = (pure r, Just s)+feedEofMaybe :: forall m t s r. (Applicative m, Monoid s) => Parser t s r -> StateT (Maybe s) (LogicT (Either String)) (m r)+feedEofMaybe p = StateT logic+ where logic :: Maybe s -> LogicT (Either String) (m r, Maybe s)+ f :: Maybe s -> forall a. ((m r, Maybe s) -> Either String a -> Either String a) -> Either String a -> Either String a+ wrap :: (r, s) -> (m r, Maybe s)+ logic s = LogicT (f s)+ f s cons nil = case feedEof (maybe id feed s p)+ of Failure msg -> Left msg+ p' -> foldr cons nil (wrap <$> completeResults p')+ wrap (r, s) = (pure r, Just s) -- | Extracts all available parsing results from a 'Parser'. The first component of the result pair is a list of -- complete results together with the unconsumed remainder of the input. If the parsing can continue further, the second@@ -276,7 +281,7 @@ instance (Monoid s, Monoid r, Semigroup r) => Monoid (Parser t s r) where mempty = return mempty- mappend = (><)+ mappend = (<>) instance (Alternative (Parser t s), Monoid s) => MonoidAlternative (Parser t s) where moptional p = p <|> mempty