diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b25c6c..b76f0ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: +- Upgrade to parsing v7.0.0, replace all `StringLike` constraints with `String` type (#76 by @jamesdbrock) + New features: Bugfixes: diff --git a/bower.json b/bower.json index 7284e1d..14a8e4b 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,7 @@ "purescript-fixed-points": "^6.0.0", "purescript-lists": "^6.0.0", "purescript-numbers": "^8.0.0", - "purescript-parsing": "^6.0.0", + "purescript-parsing": "^7.0.0", "purescript-prelude": "^5.0.0", "purescript-transformers": "^5.0.0" }, diff --git a/packages.dhall b/packages.dhall index 7a6905b..11cc28c 100644 --- a/packages.dhall +++ b/packages.dhall @@ -2,3 +2,4 @@ let upstream = https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c in upstream + with parsing.version = "v7.0.0" diff --git a/src/Data/Formatter/Parser/Number.purs b/src/Data/Formatter/Parser/Number.purs index 078a246..8741205 100644 --- a/src/Data/Formatter/Parser/Number.purs +++ b/src/Data/Formatter/Parser/Number.purs @@ -19,26 +19,26 @@ import Data.Maybe (Maybe(..)) import Data.Number (fromString) import Data.Foldable (foldMap) -parseInteger ∷ ∀ s m. Monad m ⇒ PS.StringLike s ⇒ P.ParserT s m Int +parseInteger ∷ ∀ m. Monad m ⇒ P.ParserT String m Int parseInteger = some parseDigit <#> foldDigits -parseMaybeInteger ∷ ∀ s m. Monad m ⇒ PS.StringLike s ⇒ P.ParserT s m (Maybe Int) +parseMaybeInteger ∷ ∀ m. Monad m ⇒ P.ParserT String m (Maybe Int) parseMaybeInteger = PC.optionMaybe parseInteger -parseFractional ∷ ∀ s m. Monad m ⇒ PS.StringLike s ⇒ P.ParserT s m Number +parseFractional ∷ ∀ m. Monad m ⇒ P.ParserT String m Number parseFractional = do digitStr <- (some parseDigit) <#> (foldMap show >>> ("0." <> _)) case fromString digitStr of Just n -> pure n Nothing -> P.fail ("Not a number: " <> digitStr) -parseNumber ∷ ∀ s m. Monad m ⇒ PS.StringLike s ⇒ P.ParserT s m Number +parseNumber ∷ ∀ m. Monad m ⇒ P.ParserT String m Number parseNumber = (+) <$> (parseInteger <#> toNumber) <*> (PC.option 0.0 $ PC.try $ PS.oneOf ['.', ','] *> parseFractional) -parseDigit ∷ ∀ s m. Monad m ⇒ PS.StringLike s ⇒ P.ParserT s m Int +parseDigit ∷ ∀ m. Monad m ⇒ P.ParserT String m Int parseDigit = PC.try $ PS.char `oneOfAs` [ Tuple '0' 0 , Tuple '1' 1 diff --git a/src/Data/Formatter/Parser/Utils.purs b/src/Data/Formatter/Parser/Utils.purs index 2783e25..fbe6de9 100644 --- a/src/Data/Formatter/Parser/Utils.purs +++ b/src/Data/Formatter/Parser/Utils.purs @@ -17,7 +17,7 @@ import Data.Either (Either) oneOfAs ∷ ∀ c s m f a b. Functor f ⇒ Foldable f ⇒ Monad m ⇒ (a → ParserT s m b) → f (Tuple a c) → ParserT s m c oneOfAs p xs = PC.choice $ (\(Tuple s r) → p s $> r) <$> xs -runP ∷ ∀ s a. PS.StringLike s ⇒ Parser s a → s → Either String a +runP ∷ ∀ a. Parser String a → String → Either String a runP p s = lmap printError $ runParser s (p <* PS.eof) printError ∷ ParseError → String