diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 01:49:53 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 01:49:53 +0000 |
| commit | 5a6af8a74895b548ed39649aef4a09fb53b4dbbc (patch) | |
| tree | 76b0e3b15e73bb8c51d95cda41b50843e7229151 /lib/kernel/Prototype.ml | |
| parent | 0f5161930584eaf91fd195b891ce7d9130c7b7f1 (diff) | |
| download | RNT-5a6af8a74895b548ed39649aef4a09fb53b4dbbc.tar.gz RNT-5a6af8a74895b548ed39649aef4a09fb53b4dbbc.zip | |
Avoid implementing `Directory` inline?
Diffstat (limited to 'lib/kernel/Prototype.ml')
| -rw-r--r-- | lib/kernel/Prototype.ml | 11 |
1 files changed, 6 insertions, 5 deletions
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 |
