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.