I have some simple monadic bindings, given below:
module Syntax = struct
(* For ppx_let *)
module Let_syntax = struct
let bind m ~f = fun sin ->
let sout, res = m sin in
f res sout
[@@inline always]
let return = return
let map m ~f = fun sin ->
let sout, res = m sin in
(sout, f res)
[@@inline always]
let both m1 m2 = fun sin ->
let s1, res1 = m1 sin in
let s2, res2 = m2 s1 in
(s2, (res1, res2))
[@@inline always]
end
open Let_syntax
let (let+) (m: 'c state -> 'c state * 'a) (f: 'a -> 'b) : ('c state -> 'c state * 'b) = map m ~f [@@inline always]
let (and+) = both
let (let* ) (m: 'c state -> 'c state * 'a) (f: 'a -> 'c state -> 'c state * 'b) : ('c state -> 'c state * 'b) = bind m ~f [@@inline always]
let (and* ) = both
end
The following are the contents of the dune file at project root:
(env
(dev
(flags (:standard -warn-error -A -w -39 -w -27 -w -32))
(ocamlopt_flags (:standard -O3 -inline 100 -inlining-report))
))
I have flambda installed.
However, it seems that the bind and map functions are not getting inlined. For instance, in cases of unexpected errors, the backtrace is full of references to these bind and map functions like so:
Raised at Util__Error.fail in file "lib/util/error.ml", line 10, characters 24-51
Called from Ast__Rewriter.resolve_and_find in file "lib/ast/rewriter.ml", line 811, characters 52-95
Called from Ast__Rewriter.Syntax.Let_syntax.map in file "lib/ast/rewriter.ml", line 26, characters 13-18
Called from Ast__Rewriter.Syntax.Let_syntax.map in file "lib/ast/rewriter.ml", line 25, characters 22-27
Called from Ast__Rewriter.Syntax.Let_syntax.map in file "lib/ast/rewriter.ml", line 25, characters 22-27
Called from Ast__Rewriter.Syntax.Let_syntax.bind in file "lib/ast/rewriter.ml", line 19, characters 22-27
Is this the expected behaviour? Is there a reason why these functions are not getting inlined? How can I go about troubleshooting this?