If you add explicit type annotations it can figure out which one you want. But yeah it's not great. There’s a compiler flag, `-principle` that will give an error if you are depending on such behavior, but IIUC it cause a performance hit to type checking for some reason.
I thought it affected if you were relying on the order of nominal variants though (at least it did in my experience). TBH I need to check with records, but I’m pretty sure it checks them too.
oh yeah you're right about nominal variants. i wrote "variants" and my brain autocompleted polymorphic oops ^^
i tried this exact code earlier and both `utop -principal` and `ocaml -principal https://file.ml` still accept it
first-class modules are one of those language features where every explanation i read feels incoherent _and_ completely different from every other explanation
OCaml does not have first-class modules - or at least, it’s a misnomer - having actual first-class modules means that you can pass them as any value, which is not really possible (packaged modules don’t exactly count)
kind of, iiuc they shadow which one will be used if there is no additional information, but if you give it a type signature, you can still use either one. if you actually want record fields to shadow each other, you need to use haskell :p
Comments
i tried this exact code earlier and both `utop -principal` and `ocaml -principal https://file.ml` still accept it
But it helps me think in terms of reusability.
Also you were talking about the weird thing where shadowing happens.
It has its own super powers. Specifically you can't use something before creating it