Substitute for records?

Currently i'm working, together with a friend, on an abstraction (sort of) of HaskellDB for a school-project. Basically we are generating haskell-modules similar to those generated by DBDirect in HaskellDB together with some helpers for the most common queries you'd want to run. HaskellDB has its own record system (HDBRec) and a HaskellDB-query also returns such a record. The accessor-functions for these records can later be found in DatabaseName.TableName.ColumnName.column. These should be imported qualified to avoid name clashes. This is some example code: students <- School.Students.all db mapM_ printStudentId students printStudentId rec = print $ rec!School.Students.Id.column The main problem for me here is this part: rec!School.Students.Name.column where i would rather just write rec!id This isn't possible and the other way is just too messy for my taste. It simply isn't the easy and nice syntax i had hoped for when we started to develop this. Are there any other nice substitutes for HDBRec or normal haskell records that i could use that doesn't make name clashes an issue? Mattias

Mattias Bengtsson wrote:
Currently i'm working, together with a friend, on an abstraction (sort of) of HaskellDB for a school-project. Basically we are generating haskell-modules similar to those generated by DBDirect in HaskellDB together with some helpers for the most common queries you'd want to run. HaskellDB has its own record system (HDBRec) and a HaskellDB-query also returns such a record. The accessor-functions for these records can later be found in DatabaseName.TableName.ColumnName.column. These should be imported qualified to avoid name clashes. This is some example code:
students <- School.Students.all db mapM_ printStudentId students
printStudentId rec = print $ rec!School.Students.Id.column
The main problem for me here is this part: rec!School.Students.Name.column where i would rather just write rec!id This isn't possible and the other way is just too messy for my taste. It simply isn't the easy and nice syntax i had hoped for when we started to develop this. Are there any other nice substitutes for HDBRec or normal haskell records that i could use that doesn't make name clashes an issue?
Mattias
It's not perfect, but you can make it a lot shorter by importing the modules that declare the fields with shorter names: import qualified School.Students as Students import qualified School.Students.Name as Name students <- Students.all db mapM_ printStudentId students printStudentId rec = print $ rec!Name.column But the right answer, I'm afraid, is that there is no really nice way to work with records in today's Haskell. You may want to have a look at HList [1] to see if that works better. If it does, you are very welcome to port HaskellDB to use it instead of HDBRec. /Björn [1] http://homepages.cwi.nl/~ralf/HList/
participants (2)
-
Björn Bringert
-
Mattias Bengtsson