aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/analysis/procedure.lux
blob: 25e1be3355c4946ae3fdc5b3033bf6393d4d6022 (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
(.module:
  lux
  (lux (control [monad #+ do]
                ["ex" exception #+ exception:])
       (data [maybe]
             [text]
             text/format
             (coll [dict])))
  (luxc ["&" lang]
        (lang ["la" analysis]))
  (/ ["/." common]
     ["/." host]))

(exception: #export Unknown-Procedure)

(def: procedures
  /common.Bundle
  (|> /common.procedures
      (dict.merge /host.procedures)))

(def: #export (analyse-procedure analyse eval proc-name proc-args)
  (-> &.Analyser &.Eval Text (List Code) (Meta la.Analysis))
  (<| (maybe.default (&.throw Unknown-Procedure (%t proc-name)))
      (do maybe.Monad<Maybe>
        [proc (dict.get proc-name procedures)]
        (wrap ((proc proc-name) analyse eval proc-args)))))