diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Scope.ml | 18 | ||||
| -rw-r--r-- | lib/kernel/Scope.mli | 8 |
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/kernel/Scope.ml b/lib/kernel/Scope.ml index 95896b4..23698ba 100644 --- a/lib/kernel/Scope.ml +++ b/lib/kernel/Scope.ml @@ -21,6 +21,7 @@ let relations {multigroup; schema} = Path.("multigroup" @/ multigroup @/ "schema" @/ schema @/ "relation" @/ this) let path home relation = Path.(of_list (to_list (relations home) @ [relation])) +let denial multigroup = Path.("multigroup" @/ multigroup @/ "denial" @/ this) (* A name leaves out, from the left, what it shares with its home. *) let resolve home text = @@ -112,12 +113,16 @@ module Error = struct "A relation is named relation, schema:relation or multigroup:schema:relation" ("name" |=| Concepts.Value.String name) + let malformed_denial name = + condition "malformed-name" "A denial is named denial or multigroup:denial" + ("name" |=| Concepts.Value.String name) + let moved branch = condition "serialization-conflict" "The branch moved on while this commit was made; retry it" ("branch" |=| Concepts.Value.String branch) end -let publish root ~branch ~home bindings = +let publish ?(denials = []) root ~branch ~home bindings = let open Utilities.Result in let* changes = List.map @@ -128,6 +133,17 @@ let publish root ~branch ~home bindings = bindings |> Utilities.List.sequence in + let* denied = + List.map + (fun (name, v) -> + match String.split_on_char ':' name with + | [d] when d <> "" -> Ok (denial home.multigroup, d, v) + | [m; d] when m <> "" && d <> "" -> Ok (denial m, d, v) + | _ -> Error (Error.malformed_denial name) ) + denials + |> Utilities.List.sequence + in + let changes = changes @ denied in if List.is_empty changes then Ok () else let* state = Path.lookup root Path.("system" @/ "branch" @/ branch @/ this) in diff --git a/lib/kernel/Scope.mli b/lib/kernel/Scope.mli index aabdc61..83b3309 100644 --- a/lib/kernel/Scope.mli +++ b/lib/kernel/Scope.mli @@ -42,6 +42,9 @@ val previous : val catalog : implementation Protocols.Handle.interface -> (string list, Concepts.Condition.condition) result +(** \multigroup\[m]\schema\[s]\relation, from a branch state. *) +val relations : home -> Path.t + (** \multigroup\[m]\schema\[s]\relation\[relation], from a branch state. *) val path : home -> string -> Path.t @@ -56,8 +59,11 @@ val attribute : home -> string -> string -> string option head of \system\branch\[branch], as one successor state. A multigroup or schema not there yet is made, and a value with no address is stored as a schema stores it: a program as itself, a relation as its - tuples. If the head moved meanwhile nothing changes, and it fails. *) + tuples. [denials] are named [d], in + \denial of the home multigroup, or [m:d], in that of [m]. If the head moved meanwhile, or a multigroup does not + admit the state, nothing changes, and it fails. *) val publish : + ?denials:(string * Protocols.Handle.t option) list -> Protocols.Handle.t -> branch:string -> home:home -> |
