--- | We put the 'Configuration' and 'XmlTree' arguments last so that
--- it's easy to eta reduce all of the import_foo functions that call
--- this.
---
-import_generic :: (XmlPickler a, MonadIO m, PersistEntity b, PersistBackend m)
- => (a -> [b]) -- ^ listings getter
- -> b -- ^ Dummy Listing instance needed for 'migrate'
- -> XmlTree
- -> m ImportResult -- ^ Return the number of records inserted.
-import_generic g dummy xml = do
- runMigration defaultMigrationLogger $ migrate dummy
- let root_element = unpickleDoc xpickle xml
- case root_element of
- Nothing -> return $
- ImportFailed "Could not unpickle document in import_generic."
- Just elt -> do
- ids <- mapM insert (g elt)
- return $ ImportSucceeded (length ids)
+dbimport_generic :: (XmlImport a, MonadIO m, PersistBackend m)
+ => a
+ -> m ImportResult
+dbimport_generic x = insert_xml x >> return ImportSucceeded