From: Justin B. <jgb...@gm...> - 2009-05-27 19:12:30
|
Brian, Thanks for all your hard work here. I have a few comments: * I am really uncomfortable with renaming the HaskellDB operators, both SQL and record level "<<", "#" and "!". I can understand replacing the record level stuff so HaskellDB code matches HList documentation, but the SQL operators are worrisome. How many conflicts are there? I'd rather see HList imported qualified rather than HaskellDB. * Besides naming, do queries have to be rewritten? I am wondering if it's possible to create a Compatability module for older code that can export the new HList operators under the old HaskellDB names. * I notice "emptyRecord" had to be added to the queries in TestCase.hs. Is it possible to define a new binary operator that does not have to end with "emptyRecord", but has the Nil terminator built-in? The (#) allowed that. Or is this a change introduced by not having to have columns in the same order as the DB? * Finally, I am not sure I understand the implications of removing the Attr type. Can you elaborate? Justin 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 > > |