Skip to content

Commit 9663773

Browse files
committed
Annotate all exposed functions with "since"
1 parent b15a1ce commit 9663773

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

lib/Unicode/Char/Case.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import qualified Unicode.Internal.Char.DerivedCoreProperties as P
1919
--
2020
-- prop> isLower c == Data.Char.isLower c
2121
--
22+
-- @since 0.1.0
2223
{-# INLINE isLower #-}
2324
isLower :: Char -> Bool
2425
isLower = P.isLowercase
@@ -28,6 +29,7 @@ isLower = P.isLowercase
2829
--
2930
-- prop> isUpper c == Data.Char.isUpper c
3031
--
32+
-- @since 0.1.0
3133
{-# INLINE isUpper #-}
3234
isUpper :: Char -> Bool
3335
isUpper = P.isUppercase

lib/Unicode/Char/General.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,24 +436,34 @@ isSymbol c = case generalCategory c of
436436
jamoLFirst, jamoLCount, jamoLLast :: Int
437437

438438
-- | First leading consonant jamo.
439+
--
440+
-- @since 0.1.0
439441
jamoLFirst = 0x1100
440442

441443
-- | Total count of leading consonant jamo.
442444
jamoLCount = 19
443445

444446
-- | Last leading consonant jamo.
447+
--
448+
-- @since 0.1.0
445449
jamoLLast = jamoLFirst + jamoLCount - 1
446450

447451
-- jamo vowel
448452
jamoVFirst, jamoVCount, jamoVLast :: Int
449453

450454
-- | First vowel jamo.
455+
--
456+
-- @since 0.1.0
451457
jamoVFirst = 0x1161
452458

453459
-- | Total count of vowel jamo.
460+
--
461+
-- @since 0.1.0
454462
jamoVCount = 21
455463

456464
-- | Last vowel jamo.
465+
--
466+
-- @since 0.1.0
457467
jamoVLast = jamoVFirst + jamoVCount - 1
458468

459469
-- jamo trailing
@@ -463,47 +473,67 @@ jamoTFirst, jamoTCount :: Int
463473
--
464474
-- Note that 'jamoTFirst' does not represent a valid T, it represents a missing
465475
-- T i.e. LV without a T. See comments under 'jamoTIndex' .
476+
--
477+
-- @since 0.1.0
466478
jamoTFirst = 0x11a7
467479

468480
-- | Total count of trailing consonant jamo.
481+
--
482+
-- @since 0.1.0
469483
jamoTCount = 28
470484

471485
-- | Last trailing consonant jamo.
486+
--
487+
-- @since 0.1.0
472488
jamoTLast :: Int
473489
jamoTLast = jamoTFirst + jamoTCount - 1
474490

475491
-- | Total count of all jamo characters.
476492
--
477493
-- @jamoNCount = jamoVCount * jamoTCount@
494+
--
495+
-- @since 0.1.0
478496
jamoNCount :: Int
479497
jamoNCount = 588
480498

481499
-- hangul
482500
hangulFirst, hangulLast :: Int
483501

484502
-- | Codepoint of the first pre-composed Hangul character.
503+
--
504+
-- @since 0.1.0
485505
hangulFirst = 0xac00
486506

487507
-- | Codepoint of the last Hangul character.
508+
--
509+
-- @since 0.1.0
488510
hangulLast = hangulFirst + jamoLCount * jamoVCount * jamoTCount - 1
489511

490512
-- | Determine if the given character is a precomposed Hangul syllable.
513+
--
514+
-- @since 0.1.0
491515
isHangul :: Char -> Bool
492516
isHangul c = n >= hangulFirst && n <= hangulLast
493517
where n = ord c
494518

495519
-- | Determine if the given character is a Hangul LV syllable.
520+
--
521+
-- @since 0.1.0
496522
isHangulLV :: Char -> Bool
497523
isHangulLV c = assert (jamoTCount == 28)
498524
snd (quotRem28 (ord c - hangulFirst)) == 0
499525

500526
-- | Determine whether a character is a jamo L, V or T character.
527+
--
528+
-- @since 0.1.0
501529
isJamo :: Char -> Bool
502530
isJamo c = n >= jamoLFirst && n <= jamoTLast
503531
where n = ord c
504532

505533
-- | Given a Unicode character, if it is a leading jamo, return its index in
506534
-- the list of leading jamo consonants, otherwise return 'Nothing'.
535+
--
536+
-- @since 0.1.0
507537
jamoLIndex :: Char -> Maybe Int
508538
jamoLIndex c
509539
| index >= 0 && index < jamoLCount = Just index
@@ -512,6 +542,8 @@ jamoLIndex c
512542

513543
-- | Given a Unicode character, if it is a vowel jamo, return its index in the
514544
-- list of vowel jamo, otherwise return 'Nothing'.
545+
--
546+
-- @since 0.1.0
515547
jamoVIndex :: Char -> Maybe Int
516548
jamoVIndex c
517549
| index >= 0 && index < jamoVCount = Just index
@@ -526,6 +558,7 @@ jamoVIndex c
526558
-- Decomposition" in the Conformance chapter of the Unicode standard for more
527559
-- details.
528560
--
561+
-- @since 0.1.0
529562
jamoTIndex :: Char -> Maybe Int
530563
jamoTIndex c
531564
| index > 0 && index < jamoTCount = Just index

lib/Unicode/Char/Identifiers.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,24 @@ import qualified Unicode.Internal.Char.DerivedCoreProperties as P
2222
import qualified Unicode.Internal.Char.PropList as P
2323

2424
-- | Returns 'True' if a character is an identifier continue character.
25+
--
26+
-- @since 0.2.0
2527
{-# INLINE isIDContinue #-}
2628
isIDContinue :: Char -> Bool
2729
isIDContinue = P.isID_Continue
2830

2931
-- | Returns 'True' if a character is an identifier start character.
32+
--
33+
-- @since 0.2.0
3034
{-# INLINE isIDStart #-}
3135
isIDStart :: Char -> Bool
3236
isIDStart = P.isID_Start
3337

3438
-- | Returns 'True' if a character is an identifier continue character,
3539
-- using the NFKC modifications detailed in
3640
-- [UAX #31, 5.1](https://www.unicode.org/reports/tr31/#NFKC_Modifications).
41+
--
42+
-- @since 0.2.0
3743
{-# INLINE isXIDContinue #-}
3844
isXIDContinue :: Char -> Bool
3945
isXIDContinue = P.isXID_Continue
@@ -42,16 +48,22 @@ isXIDContinue = P.isXID_Continue
4248
-- | Returns 'True' if a character is an identifier start character,
4349
-- using the NFKC modifications detailed in
4450
-- [UAX #31, 5.1](https://www.unicode.org/reports/tr31/#NFKC_Modifications).
51+
--
52+
-- @since 0.2.0
4553
{-# INLINE isXIDStart #-}
4654
isXIDStart :: Char -> Bool
4755
isXIDStart = P.isXID_Start
4856

4957
-- | Returns 'True' if a character is a pattern syntax character.
58+
--
59+
-- @since 0.2.0
5060
{-# INLINE isPatternSyntax #-}
5161
isPatternSyntax :: Char -> Bool
5262
isPatternSyntax = P.isPattern_Syntax
5363

5464
-- | Returns 'True' if a character is a pattern whitespace character.
65+
--
66+
-- @since 0.2.0
5567
{-# INLINE isPatternWhitespace #-}
5668
isPatternWhitespace :: Char -> Bool
5769
isPatternWhitespace = P.isPattern_White_Space

lib/Unicode/Char/Normalization.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,24 @@ import qualified Unicode.Internal.Char.UnicodeData.DecompositionsK as K
7373
-- | Compose a starter character (combining class 0) with a combining character
7474
-- (non-zero combining class). Returns the composed character if the starter
7575
-- combines with the combining character, returns 'Nothing' otherwise.
76+
--
77+
-- @since 0.1.0
7678
{-# INLINE compose #-}
7779
compose :: Char -> Char -> Maybe Char
7880
compose = C.compose
7981

8082
-- | Compose a starter character with another starter character. Returns the
8183
-- composed character if the two starters combine, returns 'Nothing' otherwise.
84+
--
85+
-- @since 0.1.0
8286
{-# INLINE composeStarters #-}
8387
composeStarters :: Char -> Char -> Maybe Char
8488
composeStarters = C.composeStarters
8589

8690
-- | Return 'True' if a starter character may combine with some preceding
8791
-- starter character.
92+
--
93+
-- @since 0.1.0
8894
{-# INLINE isCombiningStarter #-}
8995
isCombiningStarter :: Char -> Bool
9096
isCombiningStarter = C.isSecondStarter
@@ -98,10 +104,14 @@ isCombiningStarter = C.isSecondStarter
98104
-------------------------------------------------------------------------------
99105

100106
-- | Whether we are decomposing in canonical or compatibility mode.
107+
--
108+
-- @since 0.1.0
101109
data DecomposeMode = Canonical | Kompat
102110

103111
-- | Decompose a non-Hangul character into its canonical or compatibility
104112
-- decompositions. Note that the resulting characters may further decompose.
113+
--
114+
-- @since 0.1.0
105115
{-# INLINE decompose #-}
106116
decompose :: DecomposeMode -> Char -> [Char]
107117
decompose Canonical = D.decompose
@@ -110,6 +120,8 @@ decompose Kompat = K.decompose
110120
-- | Given a non-Hangul character determine if the character is decomposable.
111121
-- Note that in case compatibility decompositions a character may decompose
112122
-- into a single compatibility character.
123+
--
124+
-- @since 0.1.0
113125
{-# INLINE isDecomposable #-}
114126
isDecomposable :: DecomposeMode -> Char -> Bool
115127
isDecomposable Canonical = D.isDecomposable
@@ -120,6 +132,8 @@ isDecomposable Kompat = K.isDecomposable
120132
-------------------------------------------------------------------------------
121133

122134
-- | Decompose a Hangul syllable into its corresponding Jamo characters.
135+
--
136+
-- @since 0.1.0
123137
{-# INLINE decomposeHangul #-}
124138
decomposeHangul :: Char -> (Char, Char, Char)
125139
decomposeHangul c = (l, v, t)
@@ -140,11 +154,15 @@ decomposeHangul c = (l, v, t)
140154
-- Determine the combining properties of characters.
141155

142156
-- | Returns the combining class of a character.
157+
--
158+
-- @since 0.1.0
143159
{-# INLINE combiningClass #-}
144160
combiningClass :: Char -> Int
145161
combiningClass = CC.combiningClass
146162

147163
-- | Returns 'True' if a character is a combining character.
164+
--
165+
-- @since 0.1.0
148166
{-# INLINE isCombining #-}
149167
isCombining :: Char -> Bool
150168
isCombining = CC.isCombining

0 commit comments

Comments
 (0)