As the objective of the programming task I will use the unscripted, “real-world” toy project of performing character recognition on an image that many other OCR tools fail on due to very low resolution.
The concept of “data driven programming” as I am going to use this term in this post, is to structure your program from the data types and data flows rather than the micro-level implementation. This approach has been very popular in LISP in building up Domain Specific Languages top-down as if a language to solve your problem already existed, and then finish by the trivial step of implementing such a language ;)
Haskell adds the powerful concept of data types, allowing us to first model our problem from the perspective of the data types involved and their relationship, fleshing out any functions with “undefined” (or the bottom value) and thus using the compiler to validate our design from a type-level perspective before actually writing a single line of implementation.
Part 1 of my unscripted “live” data driven programming screencast focusses on fleshing out the required data types (37min):
Part 2, I go a little more into implementation, add a testing framework and split the project into two modules (54min):
You can find the code on GitHub here: haskell_ocr
More to come on my next screencast that will implement the actual low-level code. Enjoy
Here you can find the videos on YouTube.