From 208965197eeade0d1f010ea42ddc5182840b19d4 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Wed, 3 Jul 2024 16:10:06 +0200 Subject: [PATCH] core: Remove deprecated functions --- unicode-data/Changelog.md | 9 +++++++ unicode-data/lib/Unicode/Char.hs | 4 +-- unicode-data/lib/Unicode/Char/Case.hs | 32 +++--------------------- unicode-data/lib/Unicode/Char/General.hs | 23 ----------------- unicode-data/lib/Unicode/Char/Numeric.hs | 25 ------------------ unicode-data/test/Unicode/CharSpec.hs | 14 +++-------- 6 files changed, 19 insertions(+), 88 deletions(-) diff --git a/unicode-data/Changelog.md b/unicode-data/Changelog.md index aa32a6e..b182e0c 100644 --- a/unicode-data/Changelog.md +++ b/unicode-data/Changelog.md @@ -6,6 +6,15 @@ - Added `showCodePoint` to `Unicode.Char`. - Added `intToDigiT` to `Unicode.Char.Numeric`. +### Removed + +- Removed deprecated `isLetter` and `isSpace` from `Unicode.Char.General`. + Use the corresponding functions from `Unicode.Char.General.Compat` instead. +- Remove deprecated `isLower` and `isUpper` from `Unicode.Char.Case`. + Use the corresponding functions from `Unicode.Char.Case.Compat` instead. +- Removed deprecated `Unicode.Char.Numeric.isNumber`. + Use `Unicode.Char.Numeric.Compat.isNumber` instead. + ## 0.5.0 (July 2024) - Fix the inlining of `Addr#` literals and reduce their size. This results in diff --git a/unicode-data/lib/Unicode/Char.hs b/unicode-data/lib/Unicode/Char.hs index 9251003..1227341 100644 --- a/unicode-data/lib/Unicode/Char.hs +++ b/unicode-data/lib/Unicode/Char.hs @@ -46,9 +46,9 @@ where import Data.Char (chr, ord) import Unicode.Char.Case hiding (Unfold(..), Step(..)) -import Unicode.Char.Case.Compat hiding (isLower, isUpper) +import Unicode.Char.Case.Compat import Unicode.Char.General -import Unicode.Char.General.Compat hiding (isLetter, isSpace) +import Unicode.Char.General.Compat import Unicode.Char.Identifiers import Unicode.Char.Numeric import Unicode.Char.Normalization diff --git a/unicode-data/lib/Unicode/Char/Case.hs b/unicode-data/lib/Unicode/Char/Case.hs index 5f59fe9..42d2e50 100644 --- a/unicode-data/lib/Unicode/Char/Case.hs +++ b/unicode-data/lib/Unicode/Char/Case.hs @@ -16,9 +16,7 @@ module Unicode.Char.Case ( -- * Predicates isLowerCase - , isLower , isUpperCase - , isUpper -- * Case mappings -- $case @@ -57,22 +55,13 @@ import qualified Unicode.Internal.Char.SpecialCasing.UpperCaseMapping as C -- It uses the character property -- . -- +-- See: 'Unicode.Char.Case.Compat.isLower' for the legacy predicate. +-- -- @since 0.3.0 {-# INLINE isLowerCase #-} isLowerCase :: Char -> Bool isLowerCase = P.isLowercase --- | Returns 'True' for lower-case characters. --- --- It uses the character property --- . --- --- @since 0.1.0 -{-# INLINE isLower #-} -{-# DEPRECATED isLower "Use isLowerCase instead. Note that the behavior of this function does not match base:Data.Char.isLower. See Unicode.Char.Case.Compat for behavior compatible with base:Data.Char." #-} -isLower :: Char -> Bool -isLower = P.isLowercase - -- | Returns 'True' for upper-case characters. -- -- It uses the character property @@ -82,26 +71,13 @@ isLower = P.isLowercase -- @'Unicode.Char.General.generalCategory' c == -- 'Unicode.Char.General.TitlecaseLetter'@. -- +-- See: 'Unicode.Char.Case.Compat.isUpper' for the legacy predicate. +-- -- @since 0.3.0 {-# INLINE isUpperCase #-} isUpperCase :: Char -> Bool isUpperCase = P.isUppercase --- | Returns 'True' for upper-case characters. --- --- It uses the character property --- . --- --- Note: it does /not/ match title-cased letters. Those are matched using: --- @'Unicode.Char.General.generalCategory' c == --- 'Unicode.Char.General.TitlecaseLetter'@. --- --- @since 0.1.0 -{-# INLINE isUpper #-} -{-# DEPRECATED isUpper "Use isUpperCase instead. Note that the behavior of this function does not match base:Data.Char.isUpper. See Unicode.Char.Case.Compat for behavior compatible with base:Data.Char." #-} -isUpper :: Char -> Bool -isUpper = P.isUppercase - -- $case -- -- Correct case conversion rules may map one input character to two or three diff --git a/unicode-data/lib/Unicode/Char/General.hs b/unicode-data/lib/Unicode/Char/General.hs index 4560055..a222630 100644 --- a/unicode-data/lib/Unicode/Char/General.hs +++ b/unicode-data/lib/Unicode/Char/General.hs @@ -29,10 +29,6 @@ module Unicode.Char.General , isWhiteSpace , isNoncharacter - -- ** Deprecated - , isLetter - , isSpace - -- ** Re-export , isAscii , isLatin1 @@ -552,25 +548,6 @@ isNoncharacter c = ('\xFDD0' <= c && c <= '\xFDEF') || (ord c .&. 0xFFFF) >= 0xFFFE --- | Returns 'True' for alphabetic Unicode characters (lower-case, upper-case --- and title-case letters, plus letters of caseless scripts and modifiers --- letters). --- --- @since 0.1.0 -{-# INLINE isLetter #-} -{-# DEPRECATED isLetter "Use isAlphabetic instead. Note that the behavior of this function does not match base:Data.Char.isLetter. See Unicode.Char.General.Compat for behavior compatible with base:Data.Char." #-} -isLetter :: Char -> Bool -isLetter = P.isAlphabetic - --- | Returns 'True' for any whitespace characters, and the control --- characters @\\t@, @\\n@, @\\r@, @\\f@, @\\v@. --- --- @since 0.1.0 -{-# INLINE isSpace #-} -{-# DEPRECATED isSpace "Use isWhiteSpace instead. Note that the behavior of this function does not match base:Data.Char.isSpace. See Unicode.Char.General.Compat for behavior compatible with base:Data.Char." #-} -isSpace :: Char -> Bool -isSpace = P.isWhite_Space - ------------------------------------------------------------------------------- -- Korean Hangul ------------------------------------------------------------------------------- diff --git a/unicode-data/lib/Unicode/Char/Numeric.hs b/unicode-data/lib/Unicode/Char/Numeric.hs index 157985e..388e491 100644 --- a/unicode-data/lib/Unicode/Char/Numeric.hs +++ b/unicode-data/lib/Unicode/Char/Numeric.hs @@ -11,7 +11,6 @@ module Unicode.Char.Numeric ( -- * Predicates isNumeric - , isNumber -- * Numeric values , numericValue @@ -34,35 +33,11 @@ import Data.Maybe (isJust) import Data.Ratio (denominator, numerator) import GHC.Exts (Char (..), Int (..), chr#, isTrue#, (+#), (<=#), (>=#)) -import qualified Unicode.Char.Numeric.Compat as Compat import qualified Unicode.Internal.Char.DerivedNumericValues as V -- $setup -- >>> import Data.Int (Int32, Int64) --- | Selects Unicode numeric characters, including digits from various --- scripts, Roman numerals, et cetera. --- --- This function returns 'True' if its argument has one of the --- following 'Unicode.Char.General.GeneralCategory's, or 'False' otherwise: --- --- * 'Unicode.Char.General.DecimalNumber' --- * 'Unicode.Char.General.LetterNumber' --- * 'Unicode.Char.General.OtherNumber' --- --- __Note:__ a character may have a numeric value (see 'numericValue') but return --- 'False', because 'isNumber' only tests 'Unicode.Char.General.GeneralCategory': --- some CJK characters are 'Unicode.Char.General.OtherLetter' and do have a --- numeric value. Use 'isNumeric' to cover those cases as well. --- --- prop> isNumber c == Data.Char.isNumber c --- --- @since 0.3.0 -{-# DEPRECATED isNumber "Use Unicode.Char.Numeric.Compat.isNumber instead. This function will be a synonym for isNumeric in a future release. See Unicode.Char.Numeric.Compat for behavior compatible with base:Data.Char." #-} -{-# INLINE isNumber #-} -isNumber :: Char -> Bool -isNumber = Compat.isNumber - -- | Selects Unicode character with a numeric value. -- -- __Note:__ a character may have a numeric value but return 'False' with diff --git a/unicode-data/test/Unicode/CharSpec.hs b/unicode-data/test/Unicode/CharSpec.hs index 224a441..c890511 100644 --- a/unicode-data/test/Unicode/CharSpec.hs +++ b/unicode-data/test/Unicode/CharSpec.hs @@ -12,12 +12,6 @@ import Data.Ix (Ix(..)) import Data.Maybe (isJust) import qualified Unicode.Char as UChar import qualified Unicode.Char.General.Blocks as UBlocks --- [TODO] Remove the following qualified imports once isLetter and isSpace --- are removed from Unicode.Char.General -import qualified Unicode.Char.General.Compat as UCharCompat --- [TODO] Remove the following qualified imports once isUpper and isLower --- are removed from Unicode.Char.Case -import qualified Unicode.Char.Case.Compat as UCharCompat import qualified Unicode.Char.Numeric as UNumeric import qualified Unicode.Char.Numeric.Compat as UNumericCompat import qualified Unicode.Internal.Char.UnicodeData.GeneralCategory as UC @@ -134,7 +128,7 @@ spec = do Char.chr UC.MaxIsLetter `shouldBe` maxCodePointBy isLetterRef UC.MaxIsLetter `shouldSatisfy` isPlane0To3 it "Compare to base" do - UCharCompat.isLetter `shouldBeEqualToV` Char.isLetter + UChar.isLetter `shouldBeEqualToV` Char.isLetter it "isMark" do UChar.isMark `shouldBeEqualToV` Char.isMark it "isPrint" do @@ -158,7 +152,7 @@ spec = do Char.chr UC.MaxIsSpace `shouldBe` maxCodePointBy isSpaceRef UC.MaxIsSpace `shouldSatisfy` isPlane0To3 it "Compare to base" do - UCharCompat.isSpace `shouldBeEqualToV` Char.isSpace + UChar.isSpace `shouldBeEqualToV` Char.isSpace it "isSymbol" do UChar.isSymbol `shouldBeEqualToV` Char.isSymbol describe "Case" do @@ -168,7 +162,7 @@ spec = do Char.chr UC.MaxIsLower `shouldBe` maxCodePointBy isLowerRef UC.MaxIsLower `shouldSatisfy` isPlane0To3 it "Compare to base" do - UCharCompat.isLower `shouldBeEqualToV` Char.isLower + UChar.isLower `shouldBeEqualToV` Char.isLower #if MIN_VERSION_base(4,18,0) it "isLowerCase" do UChar.isLowerCase `shouldBeEqualToV` Char.isLowerCase @@ -182,7 +176,7 @@ spec = do Char.chr UC.MaxIsUpper `shouldBe` maxCodePointBy isUpperRef UC.MaxIsUpper `shouldSatisfy` isPlane0To3 it "Compare to base" do - UCharCompat.isUpper `shouldBeEqualToV` Char.isUpper + UChar.isUpper `shouldBeEqualToV` Char.isUpper #if MIN_VERSION_base(4,18,0) it "isUpperCase" do UChar.isUpperCase `shouldBeEqualToV` Char.isUpperCase