diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/EphemeralRelation.ml | 46 | ||||
| -rw-r--r-- | lib/kernel/EphemeralRelation.mli | 36 |
2 files changed, 26 insertions, 56 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 diff --git a/lib/kernel/EphemeralRelation.mli b/lib/kernel/EphemeralRelation.mli deleted file mode 100644 index d082394..0000000 --- a/lib/kernel/EphemeralRelation.mli +++ /dev/null @@ -1,36 +0,0 @@ -module type DERIVATION = sig - type plan - - (** the hash of the plan, taken over the branch-local names of its - inputs rather than over their content addresses. The idea is to - have the same expression denote one object on every branch and - at every point in time. *) - val identity : plan -> Concepts.Hash.hash - - val describe : - plan -> (Protocols.Schematics.relation_description, Concepts.Condition.condition) result - - val modes : plan -> (Concepts.Mode.t, Concepts.Condition.condition) result - - val generate : - plan -> - Protocols.Generative.binding -> - (Protocols.Handle.t, Concepts.Condition.condition) result -end - -module Make (D : DERIVATION) : sig - (** unpinned, the identity of the derivation itself; pinned to a - branch commit, the identity of that derivation against one - reconstructible state, which is the only form for which equal - identity implies equal extension. *) - val identity : ?pinned:Concepts.Hash.hash -> D.plan -> Concepts.Hash.hash - - (** edges are the handles the derivation reads, which are released - when the relation is also. Rejection of a derivation surfaces - here instead of when a cursor is being drained. *) - val derive : - ?pinned:Concepts.Hash.hash -> - ?edges:Protocols.Handle.t list -> - D.plan -> - (Protocols.Handle.t, Concepts.Condition.condition) result -end |
