aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/meta/cache.lux
blob: fb4085f0ec14511274707774cabcdf9778506d1a (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
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only Monad do)]]
   [control
    ["[0]" try (.only Try)]]
   [data
    [text
     ["%" \\format (.only format)]]]
   [world
    ["[0]" file]]]]
 ["[0]" // (.only)
  ["[0]" context (.only Context)]
  [//
   ["[0]" version]]])

(def .public (path fs context)
  (All (_ !) (-> (file.System !) Context file.Path))
  (let [/ (at fs separator)]
    (format (the context.#target context)
            / (the context.#host context)
            / (version.format //.version))))

(def .public (enabled? fs context)
  (All (_ !) (-> (file.System !) Context (! Bit)))
  (at 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)))))