packages feed

LParse 0.1.1.1 → 0.1.2.0

raw patch · 3 files changed

+13/−3 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.LParse.Atomics: peek :: (t -> Bool) -> String -> Parser r [t] ()

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Changelog
+
+## 0.1.2.0
+
+Adding `peek` function
LParse.cabal view
@@ -1,5 +1,5 @@ name:                LParse-version:             0.1.1.1+version:             0.1.2.0 synopsis:            A continuation-based parser library description:         A parser library using continuations with a possibility for failure to build parsers in a clear and concise manner. homepage:            https://github.com/MarcusVoelker/LParse#readme@@ -10,7 +10,7 @@ copyright:           (c) 2017 Marcus Völker category:            Parsing build-type:          Simple-extra-source-files:  README.md+extra-source-files:  README.md CHANGELOG.md cabal-version:       >=1.10  library
src/Text/LParse/Atomics.hs view
@@ -55,4 +55,9 @@ 
 -- | Extracts the first integer (i.e. contiguous string of digits) from the input and returns it
 integer :: Parser r String Integer
-integer = read <$> some (cParse (\s -> not (null s) && isDigit (head s)) tokenReturn "Expected digit")+integer = read <$> some (cParse (\s -> not (null s) && isDigit (head s)) tokenReturn "Expected digit")
+
+
+-- | Succeeds if the first token matches the given function, without consuming it
+peek :: (t -> Bool) -> String -> Parser r [t] ()
+peek c = cParse (c . head) noop