blob: d7a68ecb46f2e205333ec56f8f22b73659b7ef2c (
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
|
(ns lux.analyser.meta
(:require (clojure [template :refer [do-template]])
clojure.core.match
clojure.core.match.array
(lux [base :as & :refer [|let |do return return* |case]])))
;; [Utils]
(defn ^:private ident= [x y]
(|let [[px nx] x
[py ny] y]
(and (= px py)
(= nx ny))))
(def ^:private tag-prefix "lux")
;; [Values]
(defn meta-get
"(-> Ident Code (Maybe Code))"
[ident annotations]
(|case annotations
[_ (&/$Record dict)]
(loop [dict dict]
(|case dict
(&/$Cons [_k v] dict*)
(|case _k
[_ (&/$Tag k)]
(if (ident= k ident)
(&/$Some v)
(recur dict*))
_
(recur dict*))
(&/$Nil)
&/$None))
_
&/$None))
(do-template [<name> <tag-name>]
(def <name> (&/T [tag-prefix <tag-name>]))
type?-tag "type?"
alias-tag "alias"
export?-tag "export?"
tags-tag "tags"
imports-tag "imports"
)
|