aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/meta/cache.lux
blob: 17f74ccb8387e93e4a0ce59e8cfdee01bd470324 (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
36
37
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.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 [/ (of fs separator)]
    (format (the context.#host context)
            / (version.format //.version))))

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