From 0f5161930584eaf91fd195b891ce7d9130c7b7f1 Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sat, 24 Oct 2026 01:30:08 +0000 Subject: Forsake `fmap` --- lib/concepts/Configuration.ml | 2 +- lib/concepts/Encoding.ml | 12 ++++++------ lib/concepts/Tuple.ml | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/concepts') diff --git a/lib/concepts/Configuration.ml b/lib/concepts/Configuration.ml index b2c29eb..2cd29d6 100644 --- a/lib/concepts/Configuration.ml +++ b/lib/concepts/Configuration.ml @@ -62,7 +62,7 @@ let as_dictionary t tag : (dictionary, Condition.condition) result = | p -> Error (Error.malformed_pair p) ) pairs (Ok BatMap.empty) in - strip_tag tag t |> fmap as_dictionary' + strip_tag tag t |>> as_dictionary' let as_string = function Atom s -> Ok s | form -> Error (Error.expected_atom form) diff --git a/lib/concepts/Encoding.ml b/lib/concepts/Encoding.ml index d78eb28..6420817 100644 --- a/lib/concepts/Encoding.ml +++ b/lib/concepts/Encoding.ml @@ -206,7 +206,7 @@ module Value = struct let hash_of_bencode value = let open Utilities.Result in - Bencode.with_tag 'h' value |> fmap Bencode.as_string |> Result.map Hash.of_raw_string + Bencode.with_tag 'h' value |>> Bencode.as_string |> Result.map Hash.of_raw_string let bencode_of_option f option = Bencode.Tagged ('?', Option.map f option |> Option.to_list |> fun x -> Bencode.List x) @@ -214,15 +214,15 @@ module Value = struct let option_of_bencode f value = let open Utilities.Result in Bencode.with_tag '?' value - |> fmap Bencode.as_list + |>> Bencode.as_list |> Result.map Utilities.List.hd_opt - |> fmap (function None -> Ok None | Some v -> f v |> Result.map Option.some) + |>> (function None -> Ok None | Some v -> f v |> Result.map Option.some) end module Field = struct let string value = Bencode.String value let address address = Bencode.String (Hash.to_raw_string address) - let require_string key data = Bencode.field key data |> Utilities.Result.fmap Bencode.as_string + let require_string key data = Utilities.Result.(Bencode.field key data |>> Bencode.as_string) let require_address ~malformed key data = let open Utilities.Result in @@ -264,8 +264,8 @@ module Record = struct | _ -> Error (B.malformed ()) let to_blob object_ = to_bencode object_ |> Bencode.to_blob - let of_blob blob = Bencode.of_blob blob |> Utilities.Result.fmap of_bencode + let of_blob blob = Utilities.Result.(Bencode.of_blob blob |>> of_bencode) let to_bytes object_ = to_blob object_ |> Blob.bytes_of_blob - let of_bytes bytes = Bencode.of_bytes bytes |> Utilities.Result.fmap of_bencode + let of_bytes bytes = Utilities.Result.(Bencode.of_bytes bytes |>> of_bencode) end end diff --git a/lib/concepts/Tuple.ml b/lib/concepts/Tuple.ml index c2da77c..dfb7cbe 100644 --- a/lib/concepts/Tuple.ml +++ b/lib/concepts/Tuple.ml @@ -30,8 +30,8 @@ and Body : Encoding.Record.BODY = struct let of_fields data = let open Utilities.Result in - let* type_ = Encoding.Bencode.field "type" data |> fmap Encoding.Bencode.as_string in - let* kvs = Encoding.Bencode.field "attributes" data |> fmap Encoding.Bencode.as_dict in + let* type_ = Encoding.Bencode.field "type" data |>> Encoding.Bencode.as_string in + let* kvs = Encoding.Bencode.field "attributes" data |>> Encoding.Bencode.as_dict in kvs |> List.map (fun (name, v) -> value_of_bencode v |> Result.map (fun v -> name, v)) |> Utilities.List.sequence -- cgit v1.2.3