aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/lang/translation/scheme/extension.jvm.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/lang/translation/scheme/extension.jvm.lux')
-rw-r--r--stdlib/source/lux/lang/translation/scheme/extension.jvm.lux32
1 files changed, 32 insertions, 0 deletions
diff --git a/stdlib/source/lux/lang/translation/scheme/extension.jvm.lux b/stdlib/source/lux/lang/translation/scheme/extension.jvm.lux
new file mode 100644
index 000000000..6475caf68
--- /dev/null
+++ b/stdlib/source/lux/lang/translation/scheme/extension.jvm.lux
@@ -0,0 +1,32 @@
+(.module:
+ lux
+ (lux (control [monad #+ do]
+ ["ex" exception #+ exception:])
+ (data [maybe]
+ text/format
+ (coll (dictionary ["dict" unordered #+ Dict]))))
+ (//// [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)))))