aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/cache.lux
blob: 72470f228d06e064329c5169e5a6a5661744cf71 (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
(.using
 [library
  [lux "*"
   [abstract
    [monad {"+" Monad do}]]
   [control
    ["[0]" try {"+" Try}]]
   [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 (the context.#target context)
            / (the context.#host context)
            / (version.format //.version))))

(def: .public (enabled? fs context)
  (All (_ !) (-> (file.System !) Context (! Bit)))
  (# fs directory? (..path fs context)))

(def: .public (enable! ! fs context)
  (All (_ !) (-> (Monad !) (file.System !) Context (! (Try Any))))
  (do !
    [? (..enabled? fs context)]
    (if ?
      (in {try.#Success []})
      (file.make_directories ! fs (..path fs context)))))