In languages with type inference (Haskell, Scala, F#), the type system can be an invaluable tool that not only can prevent silly errors but can actually make algorithm development easier. In fact, if you’re careful with how you construct your types, you can practically make the types write the code for you!
In this talk I’ll show how moving some information about the structures in your code into the type system can convert some of the hard work of algorithm development into something more akin to assembling puzzle pieces, and I’ll give some pointers on how to do that. I’ll show how you can construct your data types so that meaningless, “impossible”, or other error conditions cannot even be represented in your structures and the awesome effects that can have on your code. I’ll walk through a couple examples to illustrate the techniques.
My examples will be in Haskell but the ideas and techniques should apply to any language with Hindley-Milner type inference, especially those with constructs similar to Haskells’ type classes.