blob: e6d2617c9e9de118f75e53861caef80841642b09 (
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
70
71
72
73
|
(.module:
[library
[lux #*
[abstract
[monad (#+ do)]]
[control
["." io (#+ IO)]
["<>" parser
["<c>" code]]
[concurrency
["." async (#+ Async)]]]
[data
[text
["%" format (#+ format)]]
[collection
["." list ("#\." functor)]]]
[type
abstract]
["." meta]
["." macro
["." code]
[syntax (#+ syntax:)
["|.|" export]
["|.|" declaration]
["|.|" annotations]]]]])
(abstract: .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 annotations [forger input output]]
(|export|.parser
($_ <>.and
|declaration|.parser
(<>.maybe |annotations|.parser)
(<c>.form ($_ <>.and <c>.local_identifier <c>.any <c>.any))))])
(macro.with_identifiers [g!_]
(do {! meta.monad}
[this_module meta.current_module_name
.let [[name vars] declaration]
g!brand (\ ! each (|>> %.code code.text)
(macro.identifier (format (%.name [this_module name]))))
.let [capability (` (..Capability (.primitive (~ g!brand)) (~ input) (~ output)))]]
(in (list (` (type: (~ export_policy)
(~ (|declaration|.format declaration))
(~ capability)))
(` (def: (~ (code.local_identifier forger))
(All ((~ g!_) (~+ (list\each code.local_identifier 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)))
)
|