aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser/primitive.lux
blob: 9102acda5281037e472467c3a9b544f9b4f4dba6 (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-real Real #la;Real]
  [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)))