(.using [library [lux (.full) [abstract [monad (.only do)]] [control ["[0]" io (.only IO)] ["<>" parser ["" code]] [concurrency ["[0]" async (.only Async)]]] [data [text ["%" format (.only format)]] [collection ["[0]" list ("[1]#[0]" functor)]]] [type [primitive (.full)]] ["[0]" meta] ["[0]" macro ["[0]" code] [syntax (.only 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 (.form (all <>.and .local .any .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))) )