diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux/control/identity.lux | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/stdlib/source/lux/control/identity.lux b/stdlib/source/lux/control/identity.lux new file mode 100644 index 000000000..da7445bc7 --- /dev/null +++ b/stdlib/source/lux/control/identity.lux @@ -0,0 +1,53 @@ +(.module: + [lux #* + [control + [equivalence (#+ Equivalence)] + [security + [capability (#+ Capability)]]] + [type + abstract]]) + +(abstract: #export (ID code entity storage) + {#.doc "A value that uniquely identifies an entity in some foreign data storage (such as a database)."} + + code + + (structure: #export (Equivalence<ID> Equivalence<code>) + (All [code entity storage] + (-> (Equivalence code) + (Equivalence (ID code entity storage)))) + (def: (= reference sample) + (:: Equivalence<code> = + (:representation reference) + (:representation sample)))) + + (type: #export (Can-Identify code storage) + (All [entity] + (Capability code + (ID code entity storage)))) + + (type: #export (Can-Anonymize code storage) + (All [entity] + (Capability (ID code entity storage) + code))) + + (type: #export (Service code storage) + [(Can-Identify code storage) + (Can-Anonymize code storage)]) + + (def: Service<_> + Service + [(|>> :abstraction) + (|>> :representation)]) + + (type: #export (Context code scope storage) + (-> (Service code storage) + (scope storage))) + + (def: #export (with-identity context) + (All [code scope] + (Ex [storage] + (-> (Context code scope storage) + (scope storage)))) + (context ..Service<_>)) + ) |