All Unkept
Posted in: Haskell, Web development  —  20 July 2007

Haskell Blog Rewrite - Session 2 - 2007-07-06

Aims

  • Create data types for models using record syntax for the fields.
  • Create an automated method for generating SQL data definition i.e. CREATE TABLE etc
  • Do things properly -- write tests for this from the very beginning

Preliminaries

  • Learn how to use QuickTest, or other testing strategies, as soon as I am in some position to know what to test.

Notes

  • Tried to start with defining my 'Post' data type, and then use a type class 'DBField' with instances for 'Int', 'String' etc that would generate corresponding SQL definition. Of course this won't work because 'Post' is a data type, and type class methods work only on instances of data type (i.e. data types are not first class values, unlike in Python, so I can't do something like the way Django does it). An alternative is to have a script that parses the models.hs file and generates SQL based on its content.
  • Changed tack. I'm going to start with the database libraries, and work from the kind of input they want, as that is likely to be a constraint. I'm starting with HaskellDB and HSQL
    • Needed to install libmysqlclient-dev to build HSQL-MySQL
  • End of session -- got HaskellDB, HSQL-MySQL installed etc, but didn't manage to get the HaskellDB tests working -- won't load my drivers for some reason.

Analysis

  • Basically I scrapped my initial plan, and changed tack completely.

Session 3 - 2007-07-13

  • Had another go at getting HSQL working, and succeeded this time, with help from comments on my rant about lack of success so far.
  • Session over, about 1 hour.

Comments §

§ On 21 July 2007, Eric Kow wrote:
228 Did you mean QuickCheck instead of QuickTest? Regards, -e

§ On 21 July 2007, luke wrote:
230 Eric: Yep, QuickCheck is what I meant, but I imagine that HUnit or something will be better. Not that I got that far anyway.

§ On 21 July 2007, Pupeno wrote:
231 QuickCheck and HUnit are two different things. HUnit is a typical unit testing framework while QuickCheck is a *new* way of testing, where you state properties about your functions and it tries to dis-prove them by appling the function to different sets of data.
Actually both may be usefull at the same time, although with some effort I believe QuickCheck can do everything that a unit testing framework does and still be practical.

Add comment

Format:

  • Javascript has to be on to get past my spam protection, and cookies, and there is a delay, sorry for any inconvenience!
  • I reserve the right to moderate comments.