aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux
blob: c3b9b9a9ed684a53a4a46429f419d23692d7da4b (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
(.module:
  [library
   [lux #*
    [abstract
     [monad (#+ do)]]
    [data
     ["." text
      ["%" format (#+ format)]]
     [collection
      ["." list ("#\." functor)]
      ["." dictionary (#+ Dictionary)]]]]]
  [// (#+ Handler Bundle)])

(def: .public empty
  Bundle
  (dictionary.empty text.hash))

(def: .public (install name anonymous)
  (All (_ s i o)
    (-> Text (Handler s i o)
        (-> (Bundle s i o) (Bundle s i o))))
  (dictionary.has name anonymous))

(def: .public (prefix prefix)
  (All (_ s i o)
    (-> Text (-> (Bundle s i o) (Bundle s i o))))
  (|>> dictionary.entries
       (list\each (function (_ [key val]) [(format prefix " " key) val]))
       (dictionary.of_list text.hash)))