From 5a6af8a74895b548ed39649aef4a09fb53b4dbbc Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sat, 24 Oct 2026 01:49:53 +0000 Subject: Avoid implementing `Directory` inline? --- lib/kernel/Prototype.ml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/kernel/Prototype.ml') diff --git a/lib/kernel/Prototype.ml b/lib/kernel/Prototype.ml index 217b221..185f12c 100644 --- a/lib/kernel/Prototype.ml +++ b/lib/kernel/Prototype.ml @@ -87,14 +87,17 @@ module Associative = struct end module Directory = struct - let of_properties props = + let of_properties' props = Protocols.Directory.make @@ object val props = BatList.to_seq props |> BatMap.of_seq method list = Ok (BatMap.keys props |> BatFingerTree.of_enum) - method find k = Ok (BatMap.find_opt k props) + method find k = match BatMap.find_opt k props with None -> Ok None | Some f -> f () end + 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 @@ -122,9 +125,7 @@ module Directory = struct method find k = let open Utilities.Result in SI.with_read storage (fun tx -> Tree.lookup tx k node) - |>> (function - | None -> Ok None - | Some x -> constructor x |> Result.map Option.some ) + |>> function None -> Ok None | Some x -> constructor x |> Result.map Option.some end end end -- cgit v1.2.3