aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux')
-rw-r--r--stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux32
1 files changed, 32 insertions, 0 deletions
diff --git a/stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux b/stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux
new file mode 100644
index 000000000..9fa0abc55
--- /dev/null
+++ b/stdlib/source/lux/language/compiler/translation/scheme/extension.jvm.lux
@@ -0,0 +1,32 @@
+(.module:
+ lux
+ (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>]
+ (compiler [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)))))