aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/platform/compiler/phase/extension/bundle.lux
blob: 5825266948c16b0e975008d00beca7875124f5d7 (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 ("list/." Functor<List>)]
     ["." dictionary (#+ Dictionary)]]]]
  [// (#+ Handler Bundle)])

(def: #export empty
  Bundle
  (dictionary.new text.Hash<Text>))

(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<Text>)))