@@ -39,10 +39,16 @@ genNamesModule moduleName = Fold step initial done
3939
4040 step acc = \ case
4141 N. SingleChar {.. } -> step' acc char name
42- N. CharRange {.. } -> foldl'
43- (\ a c -> step' a c (mkName prefix c))
44- acc
45- [start.. end]
42+ N. CharRange {.. } -> if prefix `elem` rangePrefixes
43+ then foldl'
44+ (\ a c -> step' a c (mkName prefix c))
45+ acc
46+ [start.. end]
47+ else error . mconcat $
48+ [ " Unexpected name range: "
49+ , show prefix
50+ , " . Please update the generator and the "
51+ , " Unicode.Char.General.Names* modules" ]
4652
4753 mkName prefix c = prefix <> showHexCodepointBS c
4854
@@ -95,14 +101,22 @@ genNamesModule moduleName = Fold step initial done
95101 nushu = 0xf5
96102 hangul = 0x80
97103
104+ rangePrefixes =
105+ [ " CJK COMPATIBILITY IDEOGRAPH-"
106+ , " CJK UNIFIED IDEOGRAPH-"
107+ , " TANGUT IDEOGRAPH-"
108+ , " EGYPTIAN HIEROGLYPH-"
109+ , " KHITAN SMALL SCRIPT CHARACTER-"
110+ , " NUSHU CHARACTER-" ]
111+
98112 encodeName name
99113 | BS. take 28 name == " CJK COMPATIBILITY IDEOGRAPH-" = (" " , cjkCompat, 0 , True )
100114 | BS. take 22 name == " CJK UNIFIED IDEOGRAPH-" = (" " , cjkUnified, 0 , True )
101115 | BS. take 17 name == " TANGUT IDEOGRAPH-" = (" " , tangut, 0 , True )
102116 | BS. take 20 name == " EGYPTIAN HIEROGLYPH-" = (" " , egyptianHieroglyph, 0 , True )
103117 | BS. take 30 name == " KHITAN SMALL SCRIPT CHARACTER-" = (" " , khitan, 0 , True )
104118 | BS. take 16 name == " NUSHU CHARACTER-" = (" " , nushu, 0 , True )
105- | BS. take 16 name == " HANGUL SYLLABLE " =
119+ | BS. take 16 name == " HANGUL SYLLABLE " =
106120 let ! name' = BS. drop 16 name; ! len = BS. length name'
107121 in if len <= 12
108122 then (name', hangul + len, len, True )
0 commit comments