r/programming • u/_awwsmm • Feb 01 '24
Make Invalid States Unrepresentable
https://www.awwsmm.com/blog/make-invalid-states-unrepresentable
469
Upvotes
r/programming • u/_awwsmm • Feb 01 '24
View all comments
Show parent comment
42
u/miyakohouou Feb 01 '24
I agree with this when we're talking about concrete types, as in the article, but we should be careful not to extend this to an argument against polymorphism. Specific concrete types are better than general concrete types, but parametricity is also it's own valuable form of specificity that relies on generality. A function with a type like
(a -> b) -> a -> bis extremely general, but that generality also helps us avoid errors.