aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/cache.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler/meta/cache.lux')
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache.lux39
1 files changed, 39 insertions, 0 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache.lux b/stdlib/source/library/lux/tool/compiler/meta/cache.lux
new file mode 100644
index 000000000..d9ed86253
--- /dev/null
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache.lux
@@ -0,0 +1,39 @@
+(.using
+ [library
+ [lux "*"
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" try {"+" Try}]
+ [concurrency
+ ["[0]" async {"+" Async}]]]
+ [data
+ [text
+ ["%" format {"+" format}]]]
+ [world
+ ["[0]" file]]]]
+ ["[0]" //
+ ["[0]" context {"+" Context}]
+ [//
+ ["[0]" version]]])
+
+(def: .public (path fs context)
+ (All (_ !) (-> (file.System !) Context file.Path))
+ (let [/ (# fs separator)]
+ (format (value@ context.#target context)
+ / (value@ context.#host context)
+ / (version.format //.version))))
+
+(def: .public (enabled? fs context)
+ (-> (file.System Async) Context (Async Bit))
+ (|> context
+ (..path fs)
+ (# fs directory?)))
+
+(def: .public (enable! fs context)
+ (-> (file.System Async) Context (Async (Try Any)))
+ (do [! async.monad]
+ [? (..enabled? fs context)]
+ (if ?
+ (in {try.#Success []})
+ (file.make_directories ! fs (..path fs context)))))