|
|
|
|
|
by mlthoughts2018
2628 days ago
|
|
I spent about 4 years total working professionally in Haskell, commonly using things like multi-parameter type classes, liquidhaskell, compiler extensions for fully dependent types, higher kinded types. I’ve heard the claim, “Haskell let me encode business logic into the type system” so many times, but I think it’s totally a false promise. Usually people mean design patterns like phantom types and things, and it just leads to the same spaghetti code messes as in any other paradigm. I’ve never found any cases where encoding this stuff into the type system actually resulted in verifiably more correct code as compared to doing the same thing with analogous patterns in dynamic typing languages and adding lightweight tests. You still end up needing approximately the same amount of test code either way. Yet in the statically typed case, you often pay a big constant penalty of compile time overhead delaying the work cycle, even for the best incremental compilers. |
|
Well it's working for my code base so it's not a false promise.
I find it hard going back to dynamic languages now because of how little they allow you to see the types.
> I’ve never found any cases where encoding this stuff into the type system actually resulted in verifiably more correct code
I think there is still much debate about this. Dependent type theory is the only type system I know of in which it's possible to write proofs, and therefore verify, a program... but even dependent type theory alone is a bit bothersome for the task.
In my experience it's certainly possible to write a program in Python that is reasonably correct but it takes more effort.