From 38f805040989f64180f79c66a8061b7adb0a78be Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Mon, 14 Oct 2024 13:11:11 +0200 Subject: [PATCH] OCaml5: move @ocaml.inline annotation on the `let` --- src/lib_base/skip_list.ml | 4 ++-- .../bare/structs/monad.ml | 24 +++++++++---------- .../traced/structs/monad.ml | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib_base/skip_list.ml b/src/lib_base/skip_list.ml index 1774541ceda9..e6a25cb6f3db 100644 --- a/src/lib_base/skip_list.ml +++ b/src/lib_base/skip_list.ml @@ -387,7 +387,7 @@ end) : S = struct let ( let* ) = bind module Option = struct - let (return [@ocaml.inline "always"]) = fun x -> M.return (Some x) + let[@ocaml.inline always] return x = M.return (Some x) let ( let* ) lo f = M.bind lo (function None -> M.return None | Some x -> f x) @@ -600,7 +600,7 @@ end) : S = struct include Make_monadic (struct type 'a t = 'a - let (bind [@ocaml.inline "always"]) = ( |> ) + let bind = ( |> ) let[@ocaml.inline always] return x = x end) diff --git a/src/lib_lwt_result_stdlib/bare/structs/monad.ml b/src/lib_lwt_result_stdlib/bare/structs/monad.ml index c0d0f7b97883..ad2c15d777a3 100644 --- a/src/lib_lwt_result_stdlib/bare/structs/monad.ml +++ b/src/lib_lwt_result_stdlib/bare/structs/monad.ml @@ -39,9 +39,9 @@ module Lwt_syntax = struct end module Option_syntax = struct - let (return [@ocaml.inline "always"]) = fun x -> Some x + let[@ocaml.inline always] return x = Some x - let (fail [@ocaml.inline "always"]) = None + let fail = None let return_unit = return () @@ -63,9 +63,9 @@ module Option_syntax = struct end module Result_syntax = struct - let (return [@ocaml.inline "always"]) = fun x -> Ok x + let[@ocaml.inline always] return x = Ok x - let (fail [@ocaml.inline "always"]) = fun x -> Error x + let[@ocaml.inline always] fail x = Error x let return_unit = Ok () @@ -109,9 +109,9 @@ module Result_syntax = struct end module Lwt_option_syntax = struct - let (return [@ocaml.inline "always"]) = fun x -> Lwt.return_some x + let[@ocaml.inline always] return x = Lwt.return_some x - let (fail [@ocaml.inline "always"]) = Lwt.return None + let fail = Lwt.return None let return_unit = Lwt_syntax.return_some () @@ -140,9 +140,9 @@ module Lwt_option_syntax = struct end module Lwt_result_syntax = struct - let (return [@ocaml.inline "always"]) = fun x -> Lwt.return (Ok x) + let[@ocaml.inline always] return x = Lwt.return (Ok x) - let (fail [@ocaml.inline "always"]) = fun x -> Lwt.return (Error x) + let[@ocaml.inline always] fail x = Lwt.return (Error x) let return_unit = Lwt_syntax.return_ok_unit @@ -188,8 +188,8 @@ end (* For internal use only, not advertised *) (* Like Lwt.apply but specialised for two-parameters functions *) -let (lwt_apply2 [@ocaml.inline "always"]) = - fun f x y -> try f x y with exn -> Lwt.fail exn +let[@ocaml.inline always] lwt_apply2 f x y = + try f x y with exn -> Lwt.fail exn -let (lwt_apply3 [@ocaml.inline "always"]) = - fun f a x y -> try f a x y with exn -> Lwt.fail exn +let[@ocaml.inline always] lwt_apply3 f a x y = + try f a x y with exn -> Lwt.fail exn diff --git a/src/lib_lwt_result_stdlib/traced/structs/monad.ml b/src/lib_lwt_result_stdlib/traced/structs/monad.ml index 49cd677f44b7..683756da905c 100644 --- a/src/lib_lwt_result_stdlib/traced/structs/monad.ml +++ b/src/lib_lwt_result_stdlib/traced/structs/monad.ml @@ -32,7 +32,7 @@ module Make (Trace : Traced_sigs.Trace.S) : module Traced_result_syntax = struct include Result_syntax - let (fail [@ocaml.inline "always"]) = fun e -> fail (Trace.make e) + let[@ocaml.inline always] fail e = fail (Trace.make e) let rec join_errors trace_acc = function | Ok _ :: ts -> join_errors trace_acc ts @@ -66,7 +66,7 @@ module Make (Trace : Traced_sigs.Trace.S) : module Lwt_traced_result_syntax = struct include Lwt_result_syntax - let (fail [@ocaml.inline "always"]) = fun e -> fail (Trace.make e) + let[@ocaml.inline always] fail e = fail (Trace.make e) let join ts = let open Lwt_syntax in -- GitLab