Re: the 'external lubrary' criticism. In Rust everybody says just use serde for serializing data and anyhow for error handling. But suddenly when we say use a ppx deriver in OCaml for effectively the same thing–serializing a type to a string–it's a huge problem. That's weird to me.
That's slightly disingenuous, as in the case of ppx_deriving you always need to state the type of the expression to call it, e.g.
show_file
or
[%derive.show: (int * int) list]
from the page. It's basically the same story for Format.
What many other languages do that if you have an object, you can just transform that object into a string or output it with debug formatting, without any particular support from the object. It isn't much of a chore, but it is some; and polymorphic functions now need one extra argument for the formatter.
I do recall there's a module for OCaml that can do "debug level" printing of objects by traversing their runtime structure, but that of course doesn't suite all objects.
At least in Rust it's not automatic that you can print an object in the first place :).
quamserena|3 months ago
yawaramin|3 months ago
ernst_klim|3 months ago
Derivers are a library yes, it's pretty widespread if you need derive functionality, and it can derive basic functions. Proper link:
https://github.com/ocaml-ppx/ppx_deriving?tab=readme-ov-file...
_flux|3 months ago
What many other languages do that if you have an object, you can just transform that object into a string or output it with debug formatting, without any particular support from the object. It isn't much of a chore, but it is some; and polymorphic functions now need one extra argument for the formatter.
I do recall there's a module for OCaml that can do "debug level" printing of objects by traversing their runtime structure, but that of course doesn't suite all objects.
At least in Rust it's not automatic that you can print an object in the first place :).