Monday, 10 September 2007

Type-Level Instant Insanity

I wrote an introductory tutorial about type-level programming, "Type-Level Instant Insanity", which is now available in the Monad.Reader, Issue 8 [PDF]. The tutorial implements a solution to the puzzle Instant Insanity, entirely in the Haskell type-system.

Familiarity with the syntax of the Haskell Type System is a prerequisite for understanding the details of general Haskell programming. What better way to build familiarity with something than to hack it to bits?

The point of the exercise is to demonstrate how the type system can be used to tell the compiler about details of logic, such as pre- and post-conditions of functions. Although type annotations are optional in Haskell, they can often be used to more clearly describe what the shape of a correct solution is; or, conversely, to tell the compiler what a bug looks like.

There is also a talk page for this article, so feel free to add random thoughts there, or here.

The Monad.Reader is "a quarterly magazine about functional programming. It is less formal than a journal, but somehow more enduring than a wiki page or blog post."

Please enjoy :-)