Request for feedback: HaskellDB + HList

Hi, It's come time to share something that I've been playing around with recently: a branch of HaskellDB which replaces the home-grown Record code with HList records. It's definitely not ready for primetime, but I thought it'd be a good time to post the code and solicit some feedback from the community. HaskellDB the concept is very promising, but IMHO the code still falls short of that promise. Hopefully this is a small step in the right direction -- the advantages of using HList: * Shared implementation of extensible records * Additional features from HList * Better error messages for record misuse * "Lacks" predicates * Simpler code As an example of how this can be better, a DB insert looks like so:
insert db table $ constantRecord $ film .=. "Munchie" .*. director .=. Just "Jim Wynorski" .*. emptyRecord The columns need not appear in the same order as in the database. If you forget a column, you'll get "error: No instance for (Fail (FieldNotFound (Proxy Director)))" rather than an opaque error. Using the new "insertOpt" function, Maybe columns will default to Nothing rather than needing to be specified.
The details: I haven't updated everything, but there's enough to run test/TestCases.hs under Postgresql. TestCases is probably the best place to look for examples of the new syntax for now. HList had name conflicts with HaskellDB's SQL expression language ((.*.), (.++.), etc.) My temporary band-aid is to move the expression functions to Database.HaskellDB.SqlExpr, and require people to import qualified. The Attr type is gone, columns labels are untyped now. I also replaced a few instances of primitive type-level recursion with HMap/HMapOut. This makes the code simpler, and the type signatures more complex -- type families would help a lot here, I think. Feedback welcome! You can find my darcs tree at: http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/haske... It also requires minor changes to HList, available at: http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/hlist... I'll talk to the HList people about getting those merged. Thanks! Brian Bloniarz _________________________________________________________________ Hotmail® has a new way to see what's up with your friends. http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutori...
participants (1)
-
Brian Bloniarz