aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/analysis/type.lux
blob: 6d89dd5ef326d4394887e06722369864100d65b8 (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 Any
      (analyse value))))