New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stdlib: added Printf.ikbprintf #9364
Conversation
The code is exactly the same as This generality was not initially present (in released versions) when the original issue #7110, it was added by #201 at around the same time. (I reviewed this generalizing change but didn't realize at the time that it applied to I think that there are two choices we could make:
Personally I think that (1) is the nicer option for users. This is an extension of the work currently proposed in this PR, except that:
|
@gasche is this what you had in mind ? |
Okay, I ll update that. |
My preference would be to restrict the type of |
I tend to agree with @yallop, it is probably better to keep the specific type for I also think it would be nice to add a |
5b0c9d7
to
7f117ec
Compare
stdlib/printf.ml
Outdated
@@ -22,10 +22,13 @@ let kbprintf k b (Format (fmt, _)) = | |||
make_printf (fun acc -> bufput_acc b acc; k b) End_of_acc fmt | |||
let ikfprintf k oc (Format (fmt, _)) = | |||
make_iprintf k oc fmt | |||
let ikbprintf k bc (Format (fmt, _)) = | |||
make_iprintf k bc fmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can keep the equality let ikbprintf = ikfprintf
here, even if we do not expose the equality in the interface.
stdlib/printf.mli
Outdated
@@ -147,6 +147,12 @@ val ifprintf : 'b -> ('a, 'b, 'c, unit) format4 -> 'a | |||
@since 3.10.0 | |||
*) | |||
|
|||
val ibprintf : Buffer.t -> ('a, Buffer.t, 'c, unit) format4 -> 'a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use the format
type (and not format4
) to get exactly the same type as bprintf
.
stdlib/printf.mli
Outdated
@@ -175,6 +181,13 @@ val kbprintf : (Buffer.t -> 'd) -> Buffer.t -> | |||
@since 3.10.0 | |||
*) | |||
|
|||
val ikbprintf : (Buffer.t -> 'd) -> Buffer.t -> | |||
('a, Buffer.t, 'c, 'd) format4 -> 'a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, we want to restrict 'c
to unit
to keep the exact same type as kbprintf
.
Merged, thanks for the contribution! |
fixes #7110
@Octachron please review. Thanks