aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Directory.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-10-23 23:47:27 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-10-23 23:47:27 -0300
commitff727aac88be9098cbc08e4cf6604d4fc6845f3f (patch)
tree7797e3680801c32c30ac24e54d65901abd72d960 /lib/protocols/Directory.ml
parentb2ff91614a7f1c7dd54a43bbfe88bbb6694b0a71 (diff)
downloadRNT-ff727aac88be9098cbc08e4cf6604d4fc6845f3f.tar.gz
RNT-ff727aac88be9098cbc08e4cf6604d4fc6845f3f.zip
move directory out of prototype
Diffstat (limited to 'lib/protocols/Directory.ml')
-rw-r--r--lib/protocols/Directory.ml11
1 files changed, 11 insertions, 0 deletions
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)