Skip to content

Add a few utility functions in Misc#2284

Merged
mshinwell merged 2 commits intoocaml:trunkfrom
mshinwell:misc_functions
Mar 15, 2019
Merged

Add a few utility functions in Misc#2284
mshinwell merged 2 commits intoocaml:trunkfrom
mshinwell:misc_functions

Conversation

@mshinwell
Copy link
Copy Markdown
Contributor

This GPR provides a few straightforward functions in Misc that are required by the forthcoming work on symbol types. I don't think there is value in breaking this patch down into smaller pieces, given current time constraints.

Copy link
Copy Markdown
Contributor

@trefis trefis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Option module exists in the stdlib. Shouldn't you try using it, instead of Misc.Stdlib.Option?
Also, the one in Misc I believe duplicates some of the functions of the one in the stdlib. Perhaps it would be better to look into cleaning Misc.Stdlib instead of growing it even more.

loop 0

let print ppf t =
Format.pp_print_string ppf t
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pffff.

@mshinwell
Copy link
Copy Markdown
Contributor Author

Indeed, I think these probably predate the support in the Stdlib for Option that I had forgotten about. I will see how much we can remove from Misc.

@mshinwell
Copy link
Copy Markdown
Contributor Author

@trefis Please review again. I have removed the functions from Misc.Stdlib.Option that are now in the stdlib.

Copy link
Copy Markdown
Contributor

@trefis trefis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup of Misc.Stdlib.Option is nice!
Adding a printer in there seems reasonable.

The addition of Misc.protect_writing_to_file is also fine.

I would remove the alias to Format.pp_print_string from Misc.Stdlib.String though.

@trefis
Copy link
Copy Markdown
Contributor

trefis commented Mar 6, 2019

Also, I tend to agree with Alain: I'm not sure there is much value in a changelog entry for that PR.

@mshinwell
Copy link
Copy Markdown
Contributor Author

The print function in String was put there for a reason: I'd like modules to have a uniform interface, which includes printing for all data structures.

@Drup
Copy link
Copy Markdown
Contributor

Drup commented Mar 6, 2019

The print function in String was put there for a reason: I'd like modules to have a uniform interface, which includes printing for all data structures.

I agree with that on principle, the issue is dependency order of stdlib modules.

At some point, we need to have a serious though about the exact dependency orders we want for the stdlib modules. I remember @dbuenzli being pretty burned by that for the UChar module (iirc).

That being said, the convention for pretty printing functions is pp, not print. :)

@mshinwell
Copy link
Copy Markdown
Contributor Author

@Drup Well, we need to have a serious discussion as to how printing can be added to the data structure modules in the stdlib. Let's do that elsewhere though...

@dbuenzli
Copy link
Copy Markdown
Contributor

dbuenzli commented Mar 6, 2019

I remember @dbuenzli being pretty burned by that for the UChar module (iirc).

Just for the ref this was https://caml.inria.fr/mantis/view.php?id=7500

@trefis
Copy link
Copy Markdown
Contributor

trefis commented Mar 13, 2019

I agree with that on principle, the issue is dependency order of stdlib modules.

We're not talking about the stdlib here, only of Misc.Stdlib.

Since people think it's fine I'll retract my comment and approve.

Copy link
Copy Markdown
Contributor

@trefis trefis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge once you've rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants