[Blog] 7 OCaml Gotchas

I concur with @yawaramin . IMO you’d provide a personal opinion if you showed the solution (you can write the module name in-between) and explained that you don’t like it. Here, you’re concealing a technical solution that one may find ugly but that doesn’t have risky semantic consequences and that is to the point (it only imports the exact needed name).

1 Like

I guess I have an example of how one can (ab)use the OCaml evaluation order

let ( ++ ) x y = y; x
(** Degug helper

    before:
    [if cond then
    some_value
    ]

    after:
    [if cond then
    some_value ++ warnf "debug info %s" s
    ] 
*)

1 Like

I’ll add my thoughts to your section 4: “Type inference doesn’t work well: Part 1”

  • it’s quite often that records have the same field-names, so one would need to resolve which type one means manually anyway
  • it’s a nice quality of OCaml, relative to many other languages, that code is usually very explicit about where values and types comes from - you don’t need to guess, or know the whole codebase to understand a snippet
  • I don’t think the title of this section is fair, based on my previous points

But I agree about the confusing aspect for beginners of several of your points

2 Likes