+-- When the package name and version are put together, sometimes we can
+-- end up with a package id that cannot be parsed. This will lead to
+-- difficulties when the user wants to refer to the package later, so
+-- we check that the package id can be parsed properly here.
+checkPackageId :: InstalledPackageInfo -> IO ()
+checkPackageId ipi =
+ let str = showPackageId (package ipi) in
+ case [ x | (x,ys) <- readP_to_S parsePackageId str, all isSpace ys ] of
+ [_] -> return ()
+ [] -> die ("invalid package identifier: " ++ str)
+ _ -> die ("ambiguous package identifier: " ++ str)