aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser/primitive.lux
blob: 69e4f2b07a141dee1bb30401d9d0171fa5efef9d (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)
       [macro #+ Monad<Lux>]
       (type ["TC" check]))
  (luxc ["&" base]
        (lang ["la" analysis #+ Analysis])))

## [Analysers]
(do-template [<name> <type> <tag>]
  [(def: #export (<name> value)
     (-> <type> (Lux Analysis))
     (do Monad<Lux>
       [expected macro;expected-type
        _ (&;within-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
  (Lux Analysis)
  (do Monad<Lux>
    [expected macro;expected-type
     _ (&;within-type-env
        (TC;check expected Unit))]
    (wrap #la;Unit)))