Get rid of partial functions.
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 5 May 2016 02:24:45 +0000 (03:24 +0100)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 5 May 2016 02:27:48 +0000 (03:27 +0100)
src/Rules/Libffi.hs

index 17067ad..424b552 100644 (file)
@@ -76,17 +76,18 @@ libffiRules = do
             createDirectory $ buildRootPath -/- stageString Stage0
 
             tarballs <- getDirectoryFiles "" ["libffi-tarballs/libffi*.tar.gz"]
-            when (length tarballs /= 1) $
-                 putError $ "libffiRules: exactly one libffi tarball expected"
-                              ++ "(found: " ++ show tarballs ++ ")."
+            tarball  <- case tarballs of
+                [file] -> return $ unifyPath file
+                _      -> putError $ "libffiRules: exactly one tarball expected"
+                          ++ "(found: " ++ show tarballs ++ ")."
 
-            need tarballs
-            let libname = dropExtension . dropExtension . takeFileName $ head tarballs
+            need [tarball]
+            let libname = dropExtension . dropExtension $ takeFileName tarball
 
             removeDirectory (buildRootPath -/- libname)
             -- TODO: Simplify.
             actionFinally (do
-                build $ Target libffiContext Tar tarballs [buildRootPath]
+                build $ Target libffiContext Tar [tarball] [buildRootPath]
                 moveDirectory (buildRootPath -/- libname) libffiBuildPath) $
                     removeFiles buildRootPath [libname <//> "*"]