blob: 4f85da77db0bf870051ee4120d50c6d6c89cffa6 (
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
|
## Copyright (c) Eduardo Julian. All rights reserved.
## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
## If a copy of the MPL was not distributed with this file,
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;module:
lux
(lux (control eq
codec
hash)
(data [text "Text/" Monoid<Text> Eq<Text>])))
## [Types]
## (type: Ident
## [Text Text])
## [Functions]
(do-template [<name> <side>]
[(def: #export (<name> [module name])
(-> Ident Text)
<side>)]
[module module]
[name name]
)
## [Structures]
(struct: #export _ (Eq Ident)
(def: (= [xmodule xname] [ymodule yname])
(and (Text/= xmodule ymodule)
(Text/= xname yname))))
(struct: #export _ (Codec Text Ident)
(def: (encode [module name])
(case module
"" name
_ ($_ Text/append module ";" name)))
(def: (decode input)
(if (Text/= "" input)
(#;Left (Text/append "Invalid format for Ident: " input))
(case (text;split-all-with ";" input)
(^ (list name))
(#;Right ["" name])
(^ (list module name))
(#;Right [module name])
_
(#;Left (Text/append "Invalid format for Ident: " input))))))
(struct: #export _ (Hash Ident)
(def: eq Eq<Ident>)
(def: (hash [module name])
(let [(^open) text;Hash<Text>]
(*+ (hash module) (hash name)))))
|