diff options
| author | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 01:30:08 +0000 |
|---|---|---|
| committer | Estevan Castilho <tevo@riajuu.net> | 2026-10-24 01:30:08 +0000 |
| commit | 0f5161930584eaf91fd195b891ce7d9130c7b7f1 (patch) | |
| tree | a505f4b7bfe8dc0b0efa06c42b75502aeb2f247a /lib/kernel | |
| parent | 0b1c7ca41a6d8ce41b9783153b567c16250913ff (diff) | |
| download | RNT-0f5161930584eaf91fd195b891ce7d9130c7b7f1.tar.gz RNT-0f5161930584eaf91fd195b891ce7d9130c7b7f1.zip | |
Forsake `fmap`
Diffstat (limited to 'lib/kernel')
| -rw-r--r-- | lib/kernel/Branch.ml | 17 | ||||
| -rw-r--r-- | lib/kernel/EphemeralRelation.ml | 4 | ||||
| -rw-r--r-- | lib/kernel/Merkle.ml | 14 | ||||
| -rw-r--r-- | lib/kernel/Multigroup.ml | 11 | ||||
| -rw-r--r-- | lib/kernel/Namespace.ml | 3 | ||||
| -rw-r--r-- | lib/kernel/Prototype.ml | 3 | ||||
| -rw-r--r-- | lib/kernel/Storage.ml | 2 | ||||
| -rw-r--r-- | lib/kernel/SubstantialRelation.ml | 4 | ||||
| -rw-r--r-- | lib/kernel/Tuple.ml | 6 |
9 files changed, 33 insertions, 31 deletions
diff --git a/lib/kernel/Branch.ml b/lib/kernel/Branch.ml index 561bff3..439339e 100644 --- a/lib/kernel/Branch.ml +++ b/lib/kernel/Branch.ml @@ -50,14 +50,13 @@ module Make (S : Abstract.Storage.STORAGE) = struct let of_fields fields = let open Utilities.Result in let open Concepts.Encoding in - let* multigroups = Bencode.field "multigroups" fields |> fmap Value.hash_of_bencode in + let* multigroups = Bencode.field "multigroups" fields |>> Value.hash_of_bencode in let* previous = Bencode.field "previous" fields - |> fmap - (Value.option_of_bencode (fun v -> - Value.hash_of_bencode v - |> Result.map (fun hash -> S.Hash hash) - |> Result.map (SI.Pointer.make Loader.load) ) ) + |>> Value.option_of_bencode (fun v -> + Value.hash_of_bencode v + |> Result.map (fun hash -> S.Hash hash) + |> Result.map (SI.Pointer.make Loader.load) ) in Ok {multigroups; previous} end @@ -65,7 +64,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct and Loader : sig val load : S.transaction -> S.address -> (t, Concepts.Condition.condition) result end = struct - let load tx addr = SI.get_req tx addr |> Utilities.Result.fmap Representation.of_blob + let load tx addr = Utilities.Result.(SI.get_req tx addr |>> Representation.of_blob) end let pointer_of hash = SI.Pointer.make Loader.load (S.Hash hash) @@ -73,7 +72,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct let node_of tx branch = let open Utilities.Result in MultigroupM.find tx branch.multigroups - |> fmap (Option.to_result ~none:(Error.incomplete_branch branch.multigroups)) + |>> Option.to_result ~none:(Error.incomplete_branch branch.multigroups) (* Given [root], the stored programs of this state run through the evaluators registered under it, against this very state, so an @@ -144,7 +143,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct update_only (fun node' -> Handle.require Addressable.from node' |> Result.map Addressable.address - |> fmap (fun addr -> self#deriving {branch with multigroups= addr}) ) ) ] ); + |>> (fun addr -> self#deriving {branch with multigroups= addr}) ) ) ] ); Directory.make object method list = diff --git a/lib/kernel/EphemeralRelation.ml b/lib/kernel/EphemeralRelation.ml index 3e955ba..8843d11 100644 --- a/lib/kernel/EphemeralRelation.ml +++ b/lib/kernel/EphemeralRelation.ml @@ -49,9 +49,9 @@ module Persisted = struct let open Utilities.Result in let open Concepts.Encoding in let* name = Field.require_string "name" fields in - let* schematics = Bencode.field "schema" fields |> fmap Value.hash_of_bencode in + let* schematics = Bencode.field "schema" fields |>> Value.hash_of_bencode in let* evaluator = Field.require_string "evaluator" fields in - let* code = Bencode.field "program" fields |> fmap Value.hash_of_bencode in + let* code = Bencode.field "program" fields |>> Value.hash_of_bencode in Ok {name; schematics; pointer= {evaluator; code}} end end diff --git a/lib/kernel/Merkle.ml b/lib/kernel/Merkle.ml index 6b44c41..c64a9a3 100644 --- a/lib/kernel/Merkle.ml +++ b/lib/kernel/Merkle.ml @@ -87,14 +87,14 @@ functor as_string t |> Result.map String.to_bytes |> Result.map Concepts.Blob.blob_of_bytes - |> fmap K.decode + |>> K.decode in let decode_value t = as_string t |> Result.map Concepts.Hash.of_raw_string in let decode_list f data = data - |> fmap as_list + |>> as_list |> Result.map (List.map f) - |> fmap Utilities.List.sequence + |>> Utilities.List.sequence |> Result.map BatFingerTree.of_list in function @@ -108,7 +108,7 @@ functor Ok (Trunk {keys; children}) | _ -> Error (Error.malformed_node ()) - let from_blob blob = Concepts.Encoding.Bencode.of_blob blob |> Utilities.Result.fmap of_bencode + let from_blob blob = Utilities.Result.(Concepts.Encoding.Bencode.of_blob blob |>> of_bencode) let to_bencode = let open Concepts.Encoding.Bencode in @@ -381,7 +381,7 @@ functor let rec shrink tx = function | Trunk {children; _} when BatFingerTree.size children = 1 -> - Utilities.Result.fmap (shrink tx) (find' tx (BatFingerTree.get children 0)) + Result.bind (find' tx (BatFingerTree.get children 0)) (shrink tx) | node -> Ok node let remove tx key node = @@ -454,7 +454,7 @@ functor let* () = S.put tx (S.Hash addr) data in Ok addr - let retrieve tx addr = SI.get_req tx (S.Hash addr) |> fmap V.decode + let retrieve tx addr = SI.get_req tx (S.Hash addr) |>> V.decode let find = Tree.find let from x = x let into x = x @@ -470,7 +470,7 @@ functor let of_list tx bindings = List.map (fun (k, v) -> intern tx v |> Result.map (fun addr -> k, addr)) bindings |> Utilities.List.sequence - |> fmap (Tree.of_list tx) + |>> Tree.of_list tx let remove = Tree.remove diff --git a/lib/kernel/Multigroup.ml b/lib/kernel/Multigroup.ml index 669babb..399ab30 100644 --- a/lib/kernel/Multigroup.ml +++ b/lib/kernel/Multigroup.ml @@ -90,8 +90,8 @@ module Make (S : Abstract.Storage.STORAGE) = struct let of_fields fields = let open Utilities.Result in let open Concepts.Encoding in - let* schemas = Bencode.field "schemas" fields |> fmap Value.hash_of_bencode in - let* denials = Bencode.field "denials" fields |> fmap Value.hash_of_bencode in + let* schemas = Bencode.field "schemas" fields |>> Value.hash_of_bencode in + let* denials = Bencode.field "denials" fields |>> Value.hash_of_bencode in Ok {schemas; denials} end) @@ -100,7 +100,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct let node_of tx addr = let open Utilities.Result in - T.find tx addr |> fmap (Option.to_result ~none:(Error.incomplete addr)) + T.find tx addr |>> Option.to_result ~none:(Error.incomplete addr) (* What [h] holds under [property], each to store once the write has begun, and the tree they make when it has. *) @@ -116,9 +116,10 @@ module Make (S : Abstract.Storage.STORAGE) = struct |> Utilities.List.sequence let tree_of tx admissions = + let open Utilities.Result in List.map (fun (name, store) -> store tx |> Result.map (fun addr -> name, addr)) admissions |> Utilities.List.sequence - |> Utilities.Result.fmap (T.of_list tx) + |>> T.of_list tx let admit_schema _ h = let open Utilities.Result in @@ -229,7 +230,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct let derive f node' = Protocols.Handle.require Protocols.Addressable.from node' |> Result.map Protocols.Addressable.address - |> fmap (fun addr -> self#deriving (f addr)) + |>> (fun addr -> self#deriving (f addr)) in Protocols. [ Addressable.make self; diff --git a/lib/kernel/Namespace.ml b/lib/kernel/Namespace.ml index 80c446f..efaf667 100644 --- a/lib/kernel/Namespace.ml +++ b/lib/kernel/Namespace.ml @@ -25,9 +25,10 @@ class namespace = method list = Atomic.get entries |> BatMap.keys |> BatFingerTree.of_enum |> Result.ok method find key = + let open Utilities.Option in Atomic.get entries |> BatMap.find_opt key - |> Utilities.Option.fmap Protocols.Handle.copy + |>> Protocols.Handle.copy |> Result.ok end diff --git a/lib/kernel/Prototype.ml b/lib/kernel/Prototype.ml index ea1083b..217b221 100644 --- a/lib/kernel/Prototype.ml +++ b/lib/kernel/Prototype.ml @@ -120,8 +120,9 @@ module Directory = struct method list = SI.with_read storage (Fun.flip Tree.keys node) method find k = + let open Utilities.Result in SI.with_read storage (fun tx -> Tree.lookup tx k node) - |> Utilities.Result.fmap (function + |>> (function | None -> Ok None | Some x -> constructor x |> Result.map Option.some ) end diff --git a/lib/kernel/Storage.ml b/lib/kernel/Storage.ml index da438d2..5b1b722 100644 --- a/lib/kernel/Storage.ml +++ b/lib/kernel/Storage.ml @@ -51,5 +51,5 @@ module Make (S : Abstract.Storage.STORAGE) = struct Ok address let get_req tx addr = - S.get tx addr |> Utilities.Result.fmap (Option.to_result ~none:(Error.missing_data addr)) + Utilities.Result.(S.get tx addr |>> Option.to_result ~none:(Error.missing_data addr)) end diff --git a/lib/kernel/SubstantialRelation.ml b/lib/kernel/SubstantialRelation.ml index 9cb57f0..fe9e34f 100644 --- a/lib/kernel/SubstantialRelation.ml +++ b/lib/kernel/SubstantialRelation.ml @@ -61,8 +61,8 @@ module Make (S : Abstract.Storage.STORAGE) = struct let of_fields fields = let open Utilities.Result in let open Concepts.Encoding in - let* schematics = Bencode.field "schema" fields |> fmap Value.hash_of_bencode in - let* tuples = Bencode.field "tuples" fields |> fmap Value.hash_of_bencode in + let* schematics = Bencode.field "schema" fields |>> Value.hash_of_bencode in + let* tuples = Bencode.field "tuples" fields |>> Value.hash_of_bencode in Ok {schematics; tuples} end diff --git a/lib/kernel/Tuple.ml b/lib/kernel/Tuple.ml index 41babe9..7cd952e 100644 --- a/lib/kernel/Tuple.ml +++ b/lib/kernel/Tuple.ml @@ -67,8 +67,8 @@ module Make (S : Abstract.Storage.STORAGE) = struct let of_fields data = let open Utilities.Result in let open Concepts.Encoding in - let* type_ = Bencode.field "type" data |> fmap Bencode.as_string in - let* attributes = Bencode.field "attributes" data |> fmap Value.hash_of_bencode in + let* type_ = Bencode.field "type" data |>> Bencode.as_string in + let* attributes = Bencode.field "attributes" data |>> Value.hash_of_bencode in Ok {type_; attributes} end @@ -80,7 +80,7 @@ module Make (S : Abstract.Storage.STORAGE) = struct let node tx {attributes; _} = let open Utilities.Result in AttributeM.find tx attributes - |> fmap (Option.to_result ~none:(Error.incomplete_tuple attributes)) + |>> Option.to_result ~none:(Error.incomplete_tuple attributes) let empty tx ~type_ () = let open Utilities.Result in |
