aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser/primitive.lux
blob: 0023e43e0aed83681f092da8967a0daaf14ba92e (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
(;module:
  lux
  (lux (control monad)
       [meta #+ Monad<Meta>]
       (meta (type ["TC" check])))
  (luxc ["&" base]
        (lang ["la" analysis #+ Analysis])))

## [Analysers]
(do-template [<name> <type> <tag>]
  [(def: #export (<name> value)
     (-> <type> (Meta Analysis))
     (do Monad<Meta>
       [expected meta;expected-type
        _ (&;with-type-env
            (TC;check expected <type>))]
       (wrap (<tag> value))))]

  [analyse-bool Bool #la;Bool]
  [analyse-nat  Nat  #la;Nat]
  [analyse-int  Int  #la;Int]
  [analyse-deg  Deg  #la;Deg]
  [analyse-frac Frac #la;Frac]
  [analyse-text Text #la;Text]
  )

(def: #export analyse-unit
  (Meta Analysis)
  (do Monad<Meta>
    [expected meta;expected-type
     _ (&;with-type-env
         (TC;check expected Unit))]
    (wrap #la;Unit)))