Get the latest tech news

The Type of Sprintf


Most static type systems wouldn't let you make something like sprintf, whose type is determined by a format string. Dependent types can save the day!

Obviously this code doesn't meet a full specification of sprintf, and is implemented in a pretty unoptimized way (something like \(O(N)\) time complexity in the size of the format string). I hope, however, that you can start to see that dependent types can be extremely powerful and expressive while staying completely at compile-time. Personally, I find large eliminations very useful for writing proofs, such as when I want to prove that certain ADT constructors are impossible at a certain point.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of type

type

Photo of Sprintf

Sprintf

Related news:

News photo

Thousands with Type 1 diabetes in England to receive 'artificial pancreas'

News photo

Samsung Making It Harder To Know What Type of OLED TV You're Getting

News photo

Samsung is making it harder to know what type of OLED TV you’re getting. QD-OLED or classic WOLED? Samsung reportedly won't tell.