Skip to content

Replace Data.Char.Unicode.digitToInt by Data.Char.Unicode.hexDigitToInt and Data.Char.Unicode.isDigit by Data.Char.Unicode.isDecDigit #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
"purescript-integers": "master",
"purescript-lists": "master",
"purescript-maybe": "master",
"purescript-prelude": "master",
"purescript-strings": "master",
"purescript-transformers": "master",
"purescript-unicode": "master",
"purescript-generics-rep": "master"
"purescript-unicode": "master"
},
"devDependencies": {
"purescript-assert": "master",
"purescript-console": "master",
"purescript-effect": "master",
"purescript-psci-support": "master"
}
}
1 change: 0 additions & 1 deletion spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[ "arrays"
, "assert"
, "console"
, "generics-rep"
, "effect"
, "either"
, "foldable-traversable"
Expand Down
10 changes: 5 additions & 5 deletions src/Text/Parsing/Parser/Token.purs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Control.Monad.State (gets, modify_)
import Control.MonadPlus (guard, (<|>))
import Data.Array as Array
import Data.Char (fromCharCode, toCharCode)
import Data.Char.Unicode (digitToInt, isAlpha, isAlphaNum, isDigit, isHexDigit, isOctDigit, isSpace, isUpper)
import Data.Char.Unicode (isAlpha, isAlphaNum, isDecDigit, isHexDigit, isOctDigit, isSpace, isUpper, hexDigitToInt)
import Data.Char.Unicode as Unicode
import Data.Either (Either(..))
import Data.Foldable (foldl, foldr)
Expand Down Expand Up @@ -551,7 +551,7 @@ makeTokenParser (LanguageDef languageDef)
op :: Char -> Maybe Number -> Maybe Number
op _ Nothing = Nothing
op d (Just f) = do
int' <- digitToInt d
int' <- hexDigitToInt d
pure $ ( f + toNumber int' ) / 10.0

exponent' :: ParserT String m Number
Expand Down Expand Up @@ -600,7 +600,7 @@ makeTokenParser (LanguageDef languageDef)
where
folder :: Maybe Int -> Char -> Maybe Int
folder Nothing _ = Nothing
folder (Just x) d = ((base * x) + _) <$> digitToInt d
folder (Just x) d = ((base * x) + _) <$> hexDigitToInt d

-----------------------------------------------------------
-- Operators & reserved ops
Expand Down Expand Up @@ -780,9 +780,9 @@ inCommentSingle (LanguageDef languageDef) =
-- Helper functions that should maybe go in Text.Parsing.Parser.String --
-------------------------------------------------------------------------

-- | Parse a digit. Matches any char that satisfies `Data.Char.Unicode.isDigit`.
-- | Parse a digit. Matches any char that satisfies `Data.Char.Unicode.isDecDigit`.
digit :: forall m . Monad m => ParserT String m Char
digit = satisfy isDigit <?> "digit"
digit = satisfy isDecDigit <?> "digit"

-- | Parse a hex digit. Matches any char that satisfies `Data.Char.Unicode.isHexDigit`.
hexDigit :: forall m . Monad m => ParserT String m Char
Expand Down