From 8c0690e5a58dcf2588737a6d6a48d1e7f82a73f7 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 24 Dec 2018 19:50:00 -0400 Subject: Some refactoring. --- stdlib/source/lux/control/security/privacy.lux | 29 ++++++----- stdlib/source/lux/world/file.lux | 68 +++++++++++++------------- stdlib/source/lux/world/net.lux | 2 + 3 files changed, 52 insertions(+), 47 deletions(-) diff --git a/stdlib/source/lux/control/security/privacy.lux b/stdlib/source/lux/control/security/privacy.lux index 100b76b17..e24d49acb 100644 --- a/stdlib/source/lux/control/security/privacy.lux +++ b/stdlib/source/lux/control/security/privacy.lux @@ -5,7 +5,9 @@ [apply (#+ Apply)] [monad (#+ Monad)]] [type - abstract]]) + abstract]] + [// + [capability (#+ Capability)]]) (abstract: #export (Private value label) {#.doc (doc "A value that is regarded as 'private'." @@ -19,21 +21,22 @@ ## there to prevent confusing private values from different origins. value - (type: #export (Close label) + (type: #export (Can-Conceal label) {#.doc (doc "Represents the capacity to 'privatize' a value.")} - (All [value] (-> value (Private value label)))) + (All [value] + (Capability value + (Private value label)))) - (type: #export (Open label) + (type: #export (Can-Reveal label) {#.doc (doc "Represents the capacity to 'publicize' a value.")} - (All [value] (-> (Private value label) value))) + (All [value] + (Capability (Private value label) + value))) (signature: #export (Privilege label) {#.doc (doc "Represents the privilege to both 'privatize' and 'publicize' a value.")} - (: (Close label) - conceal) - - (: (Open label) - reveal)) + [(Can-Conceal label) + (Can-Reveal label)]) (def: Privilege<_> Privilege @@ -44,10 +47,10 @@ {#.doc (doc "Represents the act of delegating privatization capacities.")} (All [value] (-> (Private value from) (Private value to)))) - (def: #export (delegation open close) + (def: #export (delegation reveal conceal) {#.doc (doc "Delegating privatization capacities.")} - (All [from to] (-> (Open from) (Close to) (Delegation from to))) - (|>> open close)) + (All [from to] (-> (Can-Reveal from) (Can-Conceal to) (Delegation from to))) + (|>> reveal conceal)) (type: #export (Context scope label) {#.doc (doc "A computational context with an associated privacy privilege.")} diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index df90ba842..f959e1af3 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -46,34 +46,34 @@ (type: #export (Can-Modify ! i) (Capability [i] (! (Error Any)))) -(signature: #export (File !) - (~~ (do-template [ ] - [(: (Can-Query ! ) - )] +(`` (signature: #export (File !) + (~~ (do-template [ ] + [(: (Can-Query ! ) + )] - [size Nat] - [last-modified Instant] - [can-execute? Bit] - [content (Dirty Binary)] - )) + [size Nat] + [last-modified Instant] + [can-execute? Bit] + [content (Dirty Binary)] + )) - (: (Can-Open ! File) - move) + (: (Can-Open ! File) + move) - (do-template [ ] - [(: (Can-Modify ! ) - )] + (~~ (do-template [ ] + [(: (Can-Modify ! ) + )] - [modify Instant] - [over-write Binary] - ) + [modify Instant] + [over-write Binary] + )) - (: (Can-Edit !) - append) + (: (Can-Edit !) + append) - (: (Can-Delete !) - delete) - ) + (: (Can-Delete !) + delete) + )) (signature: #export (Directory !) (: (Can-Query ! (List (File !))) @@ -85,20 +85,20 @@ (: (Can-Delete !) discard)) -(signature: #export (System !) - (~~ (do-template [ ] - [(: (Can-Open ! ) - )] +(`` (signature: #export (System !) + (~~ (do-template [ ] + [(: (Can-Open ! ) + )] - [file File] - [create-file File] - [directory Directory] - [create-directory Directory] - )) + [file File] + [create-file File] + [directory Directory] + [create-directory Directory] + )) - (: Text - separator) - ) + (: Text + separator) + )) (def: (async-file file) (-> (File IO) (File Promise)) diff --git a/stdlib/source/lux/world/net.lux b/stdlib/source/lux/world/net.lux index a29df5f84..a56c9c62e 100644 --- a/stdlib/source/lux/world/net.lux +++ b/stdlib/source/lux/world/net.lux @@ -10,6 +10,8 @@ (type: #export Port Nat) +(type: #export URL Text) + (type: #export Location {#address Address #port Port}) -- cgit v1.2.3