From: Colin P. A. <co...@co...> - 2009-09-15 10:20:30
|
I have the following code: -- | Get list of all top-level galleries from database topLevelGalleries :: DB.Database -> IO [Gallery] topLevelGalleries db = do let q = do t <- DB.table galleryTable DB.restrict (DB.isNull $ t DB.! parentGalleryName) return t rs <- DB.query db q return $ map newGallery rs --newGallery :: DB.Record vr -> Gallery newGallery rec = Gallery (rec DB.! galleryName) (rec DB.! parentGalleryName) (rec DB.! readImageCapabilityName) (rec DB.! uploadImageCapabilityName) (rec DB.! administerGalleryCapabilityName) The reason the signature for newGallery is commented out is that it is very hard to write. I fired up ghci and did a :t newGallery. I got: newGallery :: (Database.HaskellDB.HDBRec.Select (Database.HaskellDB.Query.Attr Database.GalleryTable.GalleryName String) r String, Database.HaskellDB.HDBRec.Select (Database.HaskellDB.Query.Attr Database.GalleryTable.ParentGalleryName (Maybe String)) r (Maybe String), Database.HaskellDB.HDBRec.Select (Database.HaskellDB.Query.Attr Database.GalleryTable.ReadImageCapabilityName String) r String, Database.HaskellDB.HDBRec.Select (Database.HaskellDB.Query.Attr Database.GalleryTable.UploadImageCapabilityName String) r String, Database.HaskellDB.HDBRec.Select (Database.HaskellDB.Query.Attr Database.GalleryTable.AdministerGalleryCapabilityName String) r String) => r -> Dragonfly.ImageGallery.ImageGallery.Gallery Well, that's a bit of a mouthful. I don't really want to type that in. I would have hoped that somwhere there was a type definition generated from this from the DBInfo, but I can't find it. Any suggestions as to where to look? -- Colin Adams Preston Lancashire |