craigaspinall.com

04 Nov 2010 - Follow the types (not the white rabbit)!

For a while I have been trying to learn Haskell as a way of getting my head completely around functional programming. I started with “Seven Languages in Seven Weeks”, moved on to “Real World Haskell”, and now, Tony Morris is very kindly donating some of his time to help me and a few other guys to get to grips with the concepts that underpin the language.

Every week, he sets exercises for us to complete, which involves writing solutions to a bunch of functions that pass the acceptance tests that he supplied. This week we are writing a parser, but the real challenge for me is that none of the tests will pass until all of the functions have been completed. Writing around 20 functions before being able to get any feedback is almost a bigger challenge than writing the functions themselves!

Tony’s advice was to “follow the types” and I’m sure he is right. If you follow the type signatures and you have a vague notion of what the function is supposed to do, there are only a limited number of options open to you. The HaskellWiki also says that “Once your code compiles it usually works”. I’m halfway through the functions and really hoping that is true! Perhaps I’ll report back in a future post.

In any case, I can already say that what I have learned so far has influenced the code I write, and I can only see good things coming from having a better understanding of type theory and functional programming.

Newer Posts

Older Posts

This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Copyright ©Craig Aspinall 2011