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/concepts/Encoding.ml | |
| parent | 0b1c7ca41a6d8ce41b9783153b567c16250913ff (diff) | |
| download | RNT-0f5161930584eaf91fd195b891ce7d9130c7b7f1.tar.gz RNT-0f5161930584eaf91fd195b891ce7d9130c7b7f1.zip | |
Forsake `fmap`
Diffstat (limited to 'lib/concepts/Encoding.ml')
| -rw-r--r-- | lib/concepts/Encoding.ml | 12 |
1 files changed, 6 insertions, 6 deletions
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 |
