aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/analysis/type.lux
blob: f85608e196635bb099bceea2c2fc07c7f7b90c48 (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
(;module:
  lux
  (lux (control monad)
       [macro]
       (lang (type ["tc" check])))
  (luxc ["&" lang]
        (lang ["la" analysis #+ Analysis])))

## These 2 analysers are somewhat special, since they require the
## means of evaluating Lux expressions at compile-time for the sake of
## computing Lux type values.
(def: #export (analyse-check analyse eval type value)
  (-> &;Analyser &;Eval Code Code (Meta Analysis))
  (do macro;Monad<Meta>
    [actualT (eval Type type)
     #let [actualT (:! Type actualT)]
     _ (&;infer actualT)]
    (&;with-type actualT
      (analyse value))))

(def: #export (analyse-coerce analyse eval type value)
  (-> &;Analyser &;Eval Code Code (Meta Analysis))
  (do macro;Monad<Meta>
    [actualT (eval Type type)
     _ (&;infer (:! Type actualT))]
    (&;with-type Top
      (analyse value))))