-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlong-id.sml
More file actions
29 lines (21 loc) · 788 Bytes
/
long-id.sml
File metadata and controls
29 lines (21 loc) · 788 Bytes
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
structure LongId = struct
open Region
type mod_id = string * region
datatype 'var long_id =
ID of 'var * region
| QID of mod_id * ('var * region) (* qualified id *)
fun eq_mod_id ((s, _) : mod_id, (s', _)) = s = s'
fun eq_long_id eq_id (a : 'var long_id, a') =
case (a, a') of
(ID x, ID x') => eq_id (x, x')
| (QID (m, x), QID (m', x')) => eq_mod_id (m, m') andalso eq_id (x, x')
| _ => false
fun str_raw_long_id str_raw_v id =
case id of
ID (x, _) => str_raw_v x
| QID ((m, _), (x, _)) => sprintf "QID ($, $)" [m, str_raw_v x]
fun str_long_id str_v id =
case id of
ID (x, _) => str_v x
| QID ((m, _), (x, _)) => m ^ ".." ^ str_v x
end