aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/procedure.jvm.lux
blob: 82b7c5d447ff6fed984f246ae5f649bef4de881e (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
(;module:
  lux
  (lux (control [monad #+ do]
                ["ex" exception #+ exception:])
       (data [maybe]
             text/format
             (coll [dict])))
  (luxc ["&" base]
        (host ["$" jvm])
        (lang ["ls" synthesis]))
  (. ["./;" common]
     ["./;" host]))

(exception: #export Unknown-Procedure)

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

(def: #export (translate-procedure translate name args)
  (-> (-> ls;Synthesis (Meta $;Inst)) Text (List ls;Synthesis)
      (Meta $;Inst))
  (<| (maybe;default (&;throw Unknown-Procedure name))
      (do maybe;Monad<Maybe>
        [proc (dict;get name procedures)]
        (wrap (proc translate args)))))