aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux
blob: a54d67425c8e86c2ec486a5d9a3044742c411123 (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
35
36
(.module:
  [lux #*
   [control
    [monad (#+ do)]
    ["ex" exception (#+ exception:)]]
   [data
    [maybe]
    [text
     format]
    [collection ["dict" dictionary (#+ Dictionary)]]]]
  [/////
   [reference (#+ Register Variable)]
   [host ["_" scheme (#+ Computation)]]
   [compiler ("operation/" Monad<Operation>)
    [synthesis (#+ Synthesis)]]]
  [//runtime (#+ Operation Translator)]
  [/common]
  ## [/host]
  )

(exception: #export (unknown-extension {message Text})
  message)

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

(def: #export (extension translate name args)
  (-> Translator Text (List Synthesis)
      (Operation Computation))
  (<| (maybe.default (compiler.throw unknown-extension (%t name)))
      (do maybe.Monad<Maybe>
        [ext (dict.get name extensions)]
        (wrap (ext translate args)))))