diff options
Diffstat (limited to '')
| -rw-r--r-- | lib/kernel/Initialization.ml | 10 | ||||
| -rw-r--r-- | lib/kernel/Merkle.ml | 17 | ||||
| -rw-r--r-- | lib/kernel/Path.ml | 5 |
3 files changed, 9 insertions, 23 deletions
diff --git a/lib/kernel/Initialization.ml b/lib/kernel/Initialization.ml index 518fe4f..bcafce6 100644 --- a/lib/kernel/Initialization.ml +++ b/lib/kernel/Initialization.ml @@ -14,15 +14,7 @@ let bind namespace (name, handle) = let namespace entries = let into = Namespace.make () in - let open Utilities.Result in - let* () = - List.fold_left - (fun acc entry -> - let* () = acc in - bind into entry ) - (Ok ()) entries - in - Ok into + Utilities.List.fold_left (fun () -> bind into) () entries |> Result.map (fun () -> into) (* A subsystem's root holds what is its own and not data: its evaluators, and whatever else it registers beside them. *) diff --git a/lib/kernel/Merkle.ml b/lib/kernel/Merkle.ml index 266a560..78ab5a5 100644 --- a/lib/kernel/Merkle.ml +++ b/lib/kernel/Merkle.ml @@ -29,9 +29,7 @@ module type TREE = functor (S : Abstract.Storage.STORAGE) (K : KEY) -> sig val insert : S.transaction -> K.t -> address -> node -> (node, Concepts.Condition.condition) result - val of_list : - S.transaction -> (K.t * address) list -> (node, Concepts.Condition.condition) result - + val of_list : S.transaction -> (K.t * address) list -> (node, Concepts.Condition.condition) result val remove : S.transaction -> K.t -> node -> (node, Concepts.Condition.condition) result val lookup : S.transaction -> K.t -> node -> (address option, Concepts.Condition.condition) result @@ -330,11 +328,9 @@ functor let open Utilities.Result in with_batch tx (fun () -> let* _ = empty_under tx in - List.fold_left - (fun node (key, value) -> - let* node = node in - insert tx key value node ) - (Ok empty) bindings ) + Utilities.List.fold_left + (fun node (key, value) -> insert tx key value node) + empty bindings ) let rec fold_left tx f acc = let open Utilities.Result in @@ -344,12 +340,11 @@ functor |> BatFingerTree.fold_left (fun acc (k, v) -> f acc k v) acc |> Result.ok | Trunk {children; _} -> - BatFingerTree.fold_left + Utilities.FingerTree.fold_left (fun acc addr -> - let* acc = acc in let* node = find' tx addr in fold_left tx f acc node ) - (Ok acc) children + acc children let keys tx node = fold_left tx (fun acc k _ -> BatFingerTree.snoc acc k) BatFingerTree.empty node diff --git a/lib/kernel/Path.ml b/lib/kernel/Path.ml index 0814b1c..a6879b6 100644 --- a/lib/kernel/Path.ml +++ b/lib/kernel/Path.ml @@ -122,13 +122,12 @@ let assoc_all handle changes = in (* each step derives from the last; only the steps in between are ours to release *) - List.fold_left + Utilities.List.fold_left (fun current change -> - let* current = current in let* next = assoc_on current change in if current != node then Handle.release current; Ok next ) - (Ok node) + node (children @ List.map (fun (_, key, value) -> key, value) here) in apply [] handle changes |
