blob: 4e011d2ca96d3576e82d1a34f8d259d92515697d (
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
|
(.module:
lux
(lux (control [monad #+ do]
["ex" exception #+ exception:])
(data [text]
text/format
(collection [list "list/" Functor<List>]
["dict" dictionary #+ Dictionary])))
[//])
(exception: #export (incorrect-arity {name Text} {arity Nat} {args Nat})
(ex.report ["Extension" (%t name)]
["Expected arity" (|> arity .int %i)]
["Actual arity" (|> args .int %i)]))
(exception: #export (invalid-syntax {name Text})
(ex.report ["Extension" name]))
## [Utils]
(def: #export (install name anonymous)
(All [s i o]
(-> Text (-> Text (//.Handler s i o))
(-> (//.Bundle s i o) (//.Bundle s i o))))
(dict.put name anonymous))
(def: #export (prefix prefix)
(All [s i o]
(-> Text (-> (//.Bundle s i o) (//.Bundle s i o))))
(|>> dict.entries
(list/map (function (_ [key val]) [(format prefix " " key) val]))
(dict.from-list text.Hash<Text>)))
|