4 ms·
I don't really agree with the article to any extreme, but imo, its a really useful pedagogical tool to "follow the types". The book "functional programming in S
by hderms 7y ago
I don't really agree with the article to any extreme, but imo, its a really useful pedagogical tool to "follow the types". The book "functional programming in Scala" uses it a lot, and it really is easy to do in some cases. Like implementing map or flatmap is really demystified by looking at the type signature first and then realizing, given how abstract it is, that there aren't really meaningful alternative implementations for the type signature.
In a more general sense, by utilizing nominal types and defensive programming, you can get a lot of mileage by making there one obvious way to do something. A canonical example being a validation function that takes User and returns ValidUser. If theres only a single function in your codebase that can do that transformation, you can actually use a (debatably simpler) principle of following the types to guide implementation, and in fact, actively prevent the wrong implementation from being written in the first place.
These things are certainly possible to varying degrees with dynamically typed languages, or statically typed OOP languages, but Ive never encountered a paradigm that makes representing invalid program states impossible to the degree that statically typed FP makes possible.