]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/DbImport.hs
Rename the ImportResult constructors.
[dead/htsn-import.git] / src / TSN / DbImport.hs
index 3646d7c34b7fce77583bac18fbf21bb36d55742a..3aeb29f26a87756e51a49f0773bf1fd53b5b499e 100644 (file)
@@ -26,7 +26,13 @@ import Text.XML.HXT.Core (
 --   'Either' with three choices. A "Info" return value means that
 --   the XML document *was* processed, so it should be removed.
 --
-data ImportResult = Err String | Info String | Succ Int
+data ImportResult =
+  ImportFailed String -- ^ Failure with an error message.
+    | ImportSkipped String -- ^ We processed the file, but didn't import it.
+                           --   The reason is contained in the second field.
+    | ImportSucceeded Int  -- ^ We did import records, and here's how many.
+    | ImportUnsupported String -- ^ We didn't know how to process this file.
+                               --   The second field should contain info.
 
 -- | Instances of this type know how to insert themselves into a
 --   Groundhog database.
@@ -50,7 +56,8 @@ import_generic g dummy xml = do
   runMigration defaultMigrationLogger $ migrate dummy
   let root_element = unpickleDoc xpickle xml
   case root_element of
-    Nothing -> return $ Err "Could not unpickle document in import_generic."
+    Nothing -> return $
+                 ImportFailed "Could not unpickle document in import_generic."
     Just elt  -> do
       ids <- mapM insert (g elt)
-      return $ Succ (length ids)
+      return $ ImportSucceeded (length ids)