From: Justin B. <jgb...@gm...> - 2009-05-18 15:39:37
|
I like the direction you are going. I looked into using HList a year or so ago and I wasn't quite up to it. The latest (unreleased) version of HaskellDB is on patch-tag at http://patch-tag.com/r/haskelldb/snapshot/current/content/pretty. Would you mind creating a patch file against that for easier review? I won't commit it until you say its ready but I'd like to see what changes you have made. No announcement has been made but I took over maintainership from Bjorn a few months ago. I hope to get a 1.0 release of HaskellDB out this summer, and having something new like this in it would be pretty sweet. On Sat, May 16, 2009 at 3:08 PM, Brian Bloniarz <ph...@ho...> wrote: > 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/haskelldb-hlist-20090516.tar.gz > It also requires minor changes to HList, available at: > > http://mysite.verizon.net/vzewxzuh/sitebuildercontent/sitebuilderfiles/hlist-20090516.tar.gz > 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. Check it out. > _______________________________________________ > Haskell-Cafe mailing list > Has...@ha... > http://www.haskell.org/mailman/listinfo/haskell-cafe > > |