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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of names

names

Photo of Type Safety

Type Safety

Related news:

News photo

State Cops Quietly Tag Thousands as Gang Members — and Feed Their Names to ICE | Gang databases are often racially biased and riddled with errors. States and cities send their flawed information to immigration authorities

News photo

Babbel Names New CEO for AI Age, Says IPO Is Off the Table

News photo

College grads shocked as names are read at commencement — by AI