aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/platform/compiler/phase/extension/bundle.lux
blob: 41879fa0c46489cb13045e3ed1deaa501ca1f08f (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)]
     ["." 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)))