blob: 84f1466149538a291a0a714a601da91a8e78ff0f (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
(.using
[library
[lux "*"
[abstract
[monad {"+" do}]]
[control
["[0]" io {"+" IO}]
["<>" parser
["<c>" code]]
[concurrency
["[0]" async {"+" Async}]]]
[data
[text
["%" format {"+" format}]]
[collection
["[0]" list ("[1]#[0]" functor)]]]
[type
[primitive "*"]]
["[0]" meta]
["[0]" macro
["[0]" code]
[syntax {"+" syntax:}
["|[0]|" export]
["|[0]|" declaration]]]]])
(primitive: .public (Capability brand input output)
(-> input output)
(def: capability
(All (_ brand input output)
(-> (-> input output)
(Capability brand input output)))
(|>> abstraction))
(def: .public (use capability input)
(All (_ brand input output)
(-> (Capability brand input output)
input
output))
((representation capability) input))
(syntax: .public (capability: [[export_policy declaration [forger input output]]
(|export|.parser
(all <>.and
|declaration|.parser
(<c>.form (all <>.and <c>.local <c>.any <c>.any))))])
(macro.with_symbols [g!_]
(do [! meta.monad]
[this_module meta.current_module_name
.let [[name vars] declaration]
g!brand (# ! each (|>> %.code code.text)
(macro.symbol (format (%.symbol [this_module name]))))
.let [capability (` (..Capability (.Primitive (~ g!brand)) (~ input) (~ output)))]]
(in (list (` (type: (~ export_policy)
(~ (|declaration|.format declaration))
(~ capability)))
(` (def: (~ (code.local forger))
(All ((~ g!_) (~+ (list#each code.local vars)))
(-> (-> (~ input) (~ output))
(~ capability)))
(~! ..capability)))
)))))
(def: .public (async capability)
(All (_ brand input output)
(-> (Capability brand input (IO output))
(Capability brand input (Async output))))
(..capability (|>> ((representation capability)) async.future)))
)
|