aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/platform/compiler/phase/extension/bundle.lux
blob: 643e3b38ccdf4432ac805d85d1fa942c0e617022 (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
(.module:
  [lux #*
   [control
    [monad (#+ do)]]
   [data
    ["." text
     format]
    [collection
     ["." list ("#/." functor)]
     ["." dictionary (#+ Dictionary)]]]]
  [// (#+ Handler Bundle)])

(def: #export empty
  Bundle
  (dictionary.new text.hash))

(def: #export (install name anonymous)
  (All [s i o]
    (-> Text (Handler s i o)
        (-> (Bundle s i o) (Bundle s i o))))
  (dictionary.put name anonymous))

(def: #export (prefix prefix)
  (All [s i o]
    (-> Text (-> (Bundle s i o) (Bundle s i o))))
  (|>> dictionary.entries
       (list/map (function (_ [key val]) [(format prefix " " key) val]))
       (dictionary.from-list text.hash)))