aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/Prototype.ml11
-rw-r--r--lib/kernel/Prototype.mli4
-rw-r--r--lib/protocols/Directory.ml11
-rw-r--r--lib/protocols/Directory.mli1
4 files changed, 12 insertions, 15 deletions
diff --git a/lib/kernel/Prototype.ml b/lib/kernel/Prototype.ml
index 185f12c..efff1af 100644
--- a/lib/kernel/Prototype.ml
+++ b/lib/kernel/Prototype.ml
@@ -98,17 +98,6 @@ module Directory = struct
let of_properties props =
List.map (fun (p, h) -> p, fun () -> Ok (Some h)) props |> of_properties'
- let children directory =
- let open Utilities.Result in
- let* listing = Protocols.Handle.require Protocols.Directory.from directory in
- let* names = Protocols.Directory.list listing in
- BatFingerTree.to_list names
- |> List.map (fun name ->
- let* found = Protocols.Directory.find listing name in
- Ok (Option.map (fun child -> name, child) found) )
- |> Utilities.List.sequence
- |> Result.map (List.filter_map Fun.id)
-
module OfTree
(S : Abstract.Storage.STORAGE)
(K : Merkle.KEY with type t = string)
diff --git a/lib/kernel/Prototype.mli b/lib/kernel/Prototype.mli
index ec1f08e..9890800 100644
--- a/lib/kernel/Prototype.mli
+++ b/lib/kernel/Prototype.mli
@@ -10,10 +10,6 @@ module Directory : sig
(string * (unit -> (Protocols.Handle.t option, Concepts.Condition.condition) result)) list ->
Protocols.Handle.protocol
- (** the names a directory lists, and what each reaches. *)
- val children :
- Protocols.Handle.t -> ((string * Protocols.Handle.t) list, Concepts.Condition.condition) result
-
module OfTree
(S : Abstract.Storage.STORAGE)
(K : Merkle.KEY with type t = string)
diff --git a/lib/protocols/Directory.ml b/lib/protocols/Directory.ml
index 232a47e..b8caca0 100644
--- a/lib/protocols/Directory.ml
+++ b/lib/protocols/Directory.ml
@@ -10,3 +10,14 @@ let make impl = Directory (impl :> implementation)
let from handle = Handle.into handle (function Directory impl -> Some impl | _ -> None)
let list i = Handle.invoke i (fun o -> o#list)
let find i name = Handle.invoke i (fun o -> o#find name)
+
+let children directory =
+ let open Utilities.Result in
+ let* listing = Handle.require from directory in
+ let* names = list listing in
+ BatFingerTree.to_list names
+ |> List.map (fun name ->
+ let* found = find listing name in
+ Ok (Option.map (fun child -> name, child) found) )
+ |> Utilities.List.sequence
+ |> Result.map (List.filter_map Fun.id)
diff --git a/lib/protocols/Directory.mli b/lib/protocols/Directory.mli
index 0d78887..77cb27a 100644
--- a/lib/protocols/Directory.mli
+++ b/lib/protocols/Directory.mli
@@ -9,3 +9,4 @@ val make : #implementation -> Handle.protocol
val from : Handle.t -> t Handle.interface option
val list : t Handle.interface -> (string BatFingerTree.t, Concepts.Condition.condition) result
val find : t Handle.interface -> string -> (Handle.t option, Concepts.Condition.condition) result
+val children : Handle.t -> ((string * Handle.t) list, Concepts.Condition.condition) result