diff options
Diffstat (limited to 'lib/kernel/EphemeralRelation.ml')
| -rw-r--r-- | lib/kernel/EphemeralRelation.ml | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/kernel/EphemeralRelation.ml b/lib/kernel/EphemeralRelation.ml index ddf005d..e1e450d 100644 --- a/lib/kernel/EphemeralRelation.ml +++ b/lib/kernel/EphemeralRelation.ml @@ -1,29 +1,35 @@ type t = - { schematics: [`Persisted of Concepts.Hash.hash - | `Temporary of (Protocols.Schematics.attribute_description BatMap.String.t) ] } + { schematics: + [ `Persisted of Concepts.Hash.hash + | `Temporary of Protocols.Schematics.attribute_description BatMap.String.t ] } module Error = struct - open Concepts.Condition - let local_constraint_not_implemented = - condition "local-constraint-not-implemented" - "Local constraints have no centralized authority for their discerniment and enforcement yet." - empty - let predicate_not_implemented = - condition "predicate-not-implemented" - "Preciate descriptions for relations is not designed yet." - empty + (* open Concepts.Condition *) end -class ephemeral_relation program address value = +class ephemeral_relation description value enumerate inputs = object (self) - inherit Lifecycle.null + inherit Lifecycle.counted + inherit Identity.of_id + method to_string = "ephemeral-relation" val relation : t = value - method local_constraints = Error Error.local_constraint_not_implemented - method predicate = Error Error.predicate_not_implemented + method destroy = List.iter Protocols.Handle.release inputs + method enumerate : (Protocols.Handle.t, Concepts.Condition.condition) result = enumerate () + method describe () = Ok (Protocols.Schematics.Relation description) - method protocol : Protocols.Handle.protocol list = - Protocols.[ Relation.make self - ; Enumerable.make self - ; Schematics.make self ] - method hash : Concepts.Hash.hash = address + method contains (tuple : Concepts.Tuple.t) = + let open Utilities.Result in + let* cursor = self#enumerate in + Fun.protect + ~finally:(fun () -> Protocols.Handle.release cursor) + (fun () -> + let* scan = Protocols.Cursor.require cursor in + Protocols.Cursor.exists scan (fun member -> + Concepts.Hash.hash_equals (Concepts.Tuple.hash member) (Concepts.Tuple.hash tuple) ) ) + + method protocols : Protocols.Handle.protocol list = + Protocols.[Relation.make self; Enumerable.make self; Schematics.make self] end + +let instantiate ?(inputs = []) description value enumerate = + new ephemeral_relation description value enumerate inputs |> Protocols.Handle.make |
