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

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

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

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