blob: bb61c05bef84787c38a266ffa92120c8a20ef597 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
(.require
[library
[lux (.except)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]
[monoid (.only Monoid)]
["[0]" interval (.only Interval)]]
[math
[number (.only hex)
["n" nat (.use "[1]#[0]" interval)]
["[0]" i64]]]
[meta
[type
[primitive (.except)]]]]]
[/// (.only Char)])
(primitive .public Block
(Interval Char)
(def .public monoid
(Monoid Block)
(implementation
(def identity
(abstraction
(interval.between n.enum n#top n#bottom)))
(def (composite left right)
(let [left (representation left)
right (representation right)]
(abstraction
(interval.between n.enum
(n.min (at left bottom)
(at right bottom))
(n.max (at left top)
(at right top))))))))
(def .public (block start additional)
(-> Char Nat Block)
(abstraction (interval.between n.enum start (n.+ additional start))))
(with_template [<name> <slot>]
[(def .public <name>
(-> Block Char)
(|>> representation (the <slot>)))]
[start interval.bottom]
[end interval.top]
)
(def .public (size block)
(-> Block Nat)
(let [start (the interval.bottom (representation block))
end (the interval.top (representation block))]
(|> end (n.- start) ++)))
(def .public (within? block char)
(All (_ a) (-> Block Char Bit))
(interval.within? (representation block) char))
)
(def .public equivalence
(Equivalence Block)
(implementation
(def (= reference subject)
(and (n.= (..start reference) (..start subject))
(n.= (..end reference) (..end subject))))))
(def .public hash
(Hash Block)
(implementation
(def equivalence ..equivalence)
(def (hash value)
(i64.or (i64.left_shifted 32 (..start value))
(..end value)))))
(with_template [<start> <end> <name>]
[(def .public <name>
Block
(let [start (hex <start>)
end (hex <end>)]
(..block start (n.- start end))))]
... Normal blocks
["0000" "007F" basic_latin]
["00A0" "00FF" latin_1_supplement]
["0100" "017F" latin_extended_a]
["0180" "024F" latin_extended_b]
["0250" "02AF" ipa_extensions]
["02B0" "02FF" spacing_modifier_letters]
["0300" "036F" combining_diacritical_marks]
["0370" "03FF" greek_and_coptic]
["0400" "04FF" cyrillic]
["0500" "052F" cyrillic_supplementary]
["0530" "058F" armenian]
["0590" "05FF" hebrew]
["0600" "06FF" arabic]
["0700" "074F" syriac]
["0780" "07BF" thaana]
["0900" "097F" devanagari]
["0980" "09FF" bengali]
["0A00" "0A7F" gurmukhi]
["0A80" "0AFF" gujarati]
["0B00" "0B7F" oriya]
["0B80" "0BFF" tamil]
["0C00" "0C7F" telugu]
["0C80" "0CFF" kannada]
["0D00" "0D7F" malayalam]
["0D80" "0DFF" sinhala]
["0E00" "0E7F" thai]
["0E80" "0EFF" lao]
["0F00" "0FFF" tibetan]
["1000" "109F" myanmar]
["10A0" "10FF" georgian]
["1100" "11FF" hangul_jamo]
["1200" "137F" ethiopic]
["13A0" "13FF" cherokee]
["1400" "167F" unified_canadian_aboriginal_syllabics]
["1680" "169F" ogham]
["16A0" "16FF" runic]
["1700" "171F" tagalog]
["1720" "173F" hanunoo]
["1740" "175F" buhid]
["1760" "177F" tagbanwa]
["1780" "17FF" khmer]
["1800" "18AF" mongolian]
["1900" "194F" limbu]
["1950" "197F" tai_le]
["19E0" "19FF" khmer_symbols]
["1D00" "1D7F" phonetic_extensions]
["1E00" "1EFF" latin_extended_additional]
["1F00" "1FFF" greek_extended]
["2000" "206F" general_punctuation]
["2070" "209F" superscripts_and_subscripts]
["20A0" "20CF" currency_symbols]
["20D0" "20FF" combining_diacritical_marks_for_symbols]
["2100" "214F" letterlike_symbols]
["2150" "218F" number_forms]
["2190" "21FF" arrows]
["2200" "22FF" mathematical_operators]
["2300" "23FF" miscellaneous_technical]
["2400" "243F" control_pictures]
["2440" "245F" optical_character_recognition]
["2460" "24FF" enclosed_alphanumerics]
["2500" "257F" box_drawing]
["2580" "259F" block_elements]
["25A0" "25FF" geometric_shapes]
["2600" "26FF" miscellaneous_symbols]
["2700" "27BF" dingbats]
["27C0" "27EF" miscellaneous_mathematical_symbols_a]
["27F0" "27FF" supplemental_arrows_a]
["2800" "28FF" braille_patterns]
["2900" "297F" supplemental_arrows_b]
["2980" "29FF" miscellaneous_mathematical_symbols_b]
["2A00" "2AFF" supplemental_mathematical_operators]
["2B00" "2BFF" miscellaneous_symbols_and_arrows]
["2E80" "2EFF" cjk_radicals_supplement]
["2F00" "2FDF" kangxi_radicals]
["2FF0" "2FFF" ideographic_description_characters]
["3000" "303F" cjk_symbols_and_punctuation]
["3040" "309F" hiragana]
["30A0" "30FF" katakana]
["3100" "312F" bopomofo]
["3130" "318F" hangul_compatibility_jamo]
["3190" "319F" kanbun]
["31A0" "31BF" bopomofo_extended]
["31F0" "31FF" katakana_phonetic_extensions]
["3200" "32FF" enclosed_cjk_letters_and_months]
["3300" "33FF" cjk_compatibility]
["3400" "4DBF" cjk_unified_ideographs_extension_a]
["4DC0" "4DFF" yijing_hexagram_symbols]
["4E00" "9FFF" cjk_unified_ideographs]
["A000" "A48F" yi_syllables]
["A490" "A4CF" yi_radicals]
["AC00" "D7AF" hangul_syllables]
["D800" "DB7F" high_surrogates]
["DB80" "DBFF" high_private_use_surrogates]
["DC00" "DFFF" low_surrogates]
["E000" "F8FF" private_use_area]
["F900" "FAFF" cjk_compatibility_ideographs]
["FB00" "FB4F" alphabetic_presentation_forms]
["FB50" "FDFF" arabic_presentation_forms_a]
["FE00" "FE0F" variation_selectors]
["FE20" "FE2F" combining_half_marks]
["FE30" "FE4F" cjk_compatibility_forms]
["FE50" "FE6F" small_form_variants]
["FE70" "FEFF" arabic_presentation_forms_b]
["FF00" "FFEF" halfwidth_and_fullwidth_forms]
["FFF0" "FFFF" specials]
... ["10000" "1007F" linear_b_syllabary]
... ["10080" "100FF" linear_b_ideograms]
... ["10100" "1013F" aegean_numbers]
... ["10300" "1032F" old_italic]
... ["10330" "1034F" gothic]
... ["10380" "1039F" ugaritic]
... ["10400" "1044F" deseret]
... ["10450" "1047F" shavian]
... ["10480" "104AF" osmanya]
... ["10800" "1083F" cypriot_syllabary]
... ["1D000" "1D0FF" byzantine_musical_symbols]
... ["1D100" "1D1FF" musical_symbols]
... ["1D300" "1D35F" tai_xuan_jing_symbols]
... ["1D400" "1D7FF" mathematical_alphanumeric_symbols]
... ["20000" "2A6DF" cjk_unified_ideographs_extension_b]
... ["2F800" "2FA1F" cjk_compatibility_ideographs_supplement]
... ["E0000" "E007F" tags]
... Specialized blocks
["0030" "0039" numeric]
["0041" "005A" upper_case]
["0061" "007A" lower_case]
)
|