4 ms·
I've heard that, but never seen an example*. If the type system complains of an issue in other code after a local change, doesn't that mean that the other code
by BoppreH 3y ago
I've heard that, but never seen an example*. If the type system complains of an issue in other code after a local change, doesn't that mean that the other code indeed needs updating (modulo false positives, which should be rarer with granular types).
Or is this about libraries and API compatibility?
* I have seen examples of spooky-action-at-a-distance where usage of a function changes its inferred type, but that goes away if functions are allowed to have union types, which is complicated but not impossible. See: https://github.com/microsoft/TypeScript/issues/15114 https://github.com/microsoft/TypeScript/issues/15114
- nu11ptr 3y agoTry writing a larger OCaml program and not using interface files. It definitely happens.
- BoppreH 3y agoI've never used OCaml, so I'm curious to what exactly happens, and if language design can prevent that. If I download a random project and delete the interface files, will that be enough to see issues, or is it something that happens when writing new code?
- nu11ptr 3y agoIf you delete your interface files and then change the type used when calling a function it can cascade through your program and change the type of the function parameter. For this reason, I generally feel function level explicit types are a fair compromise. However, making that convention instead of required (so as to allow fast prototyping) is probably fine.
- iopq 3y agoJust require it for public functions. Your own code can be as messy as you want unser the hood
- Narishma 3y ago> If the type system complains of an issue in other code after a local change, doesn't that mean that the other code indeed needs updating The problem is when it doesn't complain but instead infers some different type that happens to match.