Skip to content

Commit

Permalink
core: Remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Jul 3, 2024
1 parent 76bd253 commit 2089651
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 88 deletions.
9 changes: 9 additions & 0 deletions unicode-data/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions unicode-data/lib/Unicode/Char.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 4 additions & 28 deletions unicode-data/lib/Unicode/Char/Case.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
module Unicode.Char.Case
( -- * Predicates
isLowerCase
, isLower
, isUpperCase
, isUpper
-- * Case mappings
-- $case

Expand Down Expand Up @@ -57,22 +55,13 @@ import qualified Unicode.Internal.Char.SpecialCasing.UpperCaseMapping as C
-- It uses the character property
-- <https://www.unicode.org/reports/tr44/#Lowercase Lowercase>.
--
-- 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
-- <https://www.unicode.org/reports/tr44/#Lowercase Lowercase>.
--
-- @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
Expand All @@ -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
-- <https://www.unicode.org/reports/tr44/#Uppercase Uppercase>.
--
-- 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
Expand Down
23 changes: 0 additions & 23 deletions unicode-data/lib/Unicode/Char/General.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ module Unicode.Char.General
, isWhiteSpace
, isNoncharacter

-- ** Deprecated
, isLetter
, isSpace

-- ** Re-export
, isAscii
, isLatin1
Expand Down Expand Up @@ -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
-------------------------------------------------------------------------------
Expand Down
25 changes: 0 additions & 25 deletions unicode-data/lib/Unicode/Char/Numeric.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
module Unicode.Char.Numeric
( -- * Predicates
isNumeric
, isNumber

-- * Numeric values
, numericValue
Expand All @@ -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
Expand Down
14 changes: 4 additions & 10 deletions unicode-data/test/Unicode/CharSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2089651

Please sign in to comment.