Get the latest tech news
Names are not type safety (2020)
Haskell programmers spend a lot of time talking about type safety. The Haskell school of program construction advocates “capturing invariants in the type system” and “making illegal states unrepresentable,” both of which sound like compelling goals, but are rather vague on the techniques used to achieve them.
The Haskell school of program construction advocates “capturing invariants in the type system” and “making illegal states unrepresentable,” both of which sound like compelling goals, but are rather vague on the techniques used to achieve them. Since the only way to construct or consume NonEmpty values is to use the functions in Data.List.NonEmpty.Newtype ’s exported API, the above implementation makes it impossible for clients to violate the non-emptiness invariant. More broadly, this is a continuation of a theme I’ve been trying to convey from different angles over the past year: type systems are tools, and we should be more conscious and intentional about what they actually do and how to use them effectively.
Or read this on Hacker News