blob: f42c19e201131e7e41c0246d279a0d461da74244 (
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
|
(.require
[library
[lux (.except)
[abstract
[equivalence (.only Equivalence)]
["[0]" hash (.only Hash)]]
[control
["[0]" maybe (.use "[1]#[0]" functor)]]
[data
["[0]" text (.only)
["%" \\format (.only format)]
["[0]" encoding (.only Encoding)]]]
[meta
[type
["[0]" primitive (.except def)]]]]]
[/
["[0]" language (.only Language)]
["[0]" territory (.only Territory)]])
(primitive.def .public Locale
Text
(def territory_separator "_")
(def encoding_separator ".")
(def .public (locale language territory encoding)
(-> Language (Maybe Territory) (Maybe Encoding) Locale)
(abstraction (format (language.code language)
(|> territory
(maybe#each (|>> territory.long_code (format ..territory_separator)))
(maybe.else ""))
(|> encoding
(maybe#each (|>> encoding.name (format ..encoding_separator)))
(maybe.else "")))))
(def .public code
(-> Locale Text)
(|>> representation))
(def .public hash
(Hash Locale)
(at hash.functor each ..code text.hash))
(def .public equivalence
(Equivalence Locale)
(at ..hash equivalence))
)
|