Skip to content

Commit d48e10a

Browse files
authored
Replace Data.Char.Unicode.digitToInt by Data.Char.Unicode.hexDigitToInt and Data.Char.Unicode.isDigit by Data.Char.Unicode.isDecDigit (#103)
* Replace Data.Char.Unicode.digitToInt by Data.Char.Unicode.hexDigitToInt * Replace Data.Char.Unicode.isDigit by Data.Char.Unicode.isDecDigit * Import Data.Generic.Rep from prelude
1 parent b0d23a3 commit d48e10a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
"purescript-integers": "master",
2828
"purescript-lists": "master",
2929
"purescript-maybe": "master",
30+
"purescript-prelude": "master",
3031
"purescript-strings": "master",
3132
"purescript-transformers": "master",
32-
"purescript-unicode": "master",
33-
"purescript-generics-rep": "master"
33+
"purescript-unicode": "master"
3434
},
3535
"devDependencies": {
3636
"purescript-assert": "master",
3737
"purescript-console": "master",
38+
"purescript-effect": "master",
3839
"purescript-psci-support": "master"
3940
}
4041
}

spago.dhall

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[ "arrays"
44
, "assert"
55
, "console"
6-
, "generics-rep"
76
, "effect"
87
, "either"
98
, "foldable-traversable"

src/Text/Parsing/Parser/Token.purs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import Control.Monad.State (gets, modify_)
2828
import Control.MonadPlus (guard, (<|>))
2929
import Data.Array as Array
3030
import Data.Char (fromCharCode, toCharCode)
31-
import Data.Char.Unicode (digitToInt, isAlpha, isAlphaNum, isDigit, isHexDigit, isOctDigit, isSpace, isUpper)
31+
import Data.Char.Unicode (isAlpha, isAlphaNum, isDecDigit, isHexDigit, isOctDigit, isSpace, isUpper, hexDigitToInt)
3232
import Data.Char.Unicode as Unicode
3333
import Data.Either (Either(..))
3434
import Data.Foldable (foldl, foldr)
@@ -551,7 +551,7 @@ makeTokenParser (LanguageDef languageDef)
551551
op :: Char -> Maybe Number -> Maybe Number
552552
op _ Nothing = Nothing
553553
op d (Just f) = do
554-
int' <- digitToInt d
554+
int' <- hexDigitToInt d
555555
pure $ ( f + toNumber int' ) / 10.0
556556

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

605605
-----------------------------------------------------------
606606
-- Operators & reserved ops
@@ -780,9 +780,9 @@ inCommentSingle (LanguageDef languageDef) =
780780
-- Helper functions that should maybe go in Text.Parsing.Parser.String --
781781
-------------------------------------------------------------------------
782782

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

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

0 commit comments

Comments
 (0)