From bfaff48e91dd9f2f3d94739851ab18e7d872c7ff Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Sun, 7 Oct 2012 18:06:08 +0200 Subject: runtests.hs: Use listToMaybe/fromMaybe instead of safeHead/maybe --- tests/html-tests/runtests.hs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tests/html-tests/runtests.hs') diff --git a/tests/html-tests/runtests.hs b/tests/html-tests/runtests.hs index 2f218d17..28bf2f7e 100644 --- a/tests/html-tests/runtests.hs +++ b/tests/html-tests/runtests.hs @@ -68,12 +68,12 @@ test = do (_, conf) <- configure normal (Just ghcPath) Nothing defaultProgramConfiguration pkgIndex <- getInstalledPackages normal [GlobalPackageDB] conf let mkDep pkgName = - maybe (error "Couldn't find test dependencies") id $ do + fromMaybe (error "Couldn't find test dependencies") $ do let pkgs = lookupPackageName pkgIndex (PackageName pkgName) - (_, pkgs') <- safeHead pkgs - pkg <- safeHead pkgs' - ifacePath <- safeHead (haddockInterfaces pkg) - htmlPath <- safeHead (haddockHTMLs pkg) + (_, pkgs') <- listToMaybe pkgs + pkg <- listToMaybe pkgs' + ifacePath <- listToMaybe (haddockInterfaces pkg) + htmlPath <- listToMaybe (haddockHTMLs pkg) return ("-i " ++ htmlPath ++ "," ++ ifacePath) let base = mkDep "base" @@ -90,10 +90,6 @@ test = do wait handle "*** Haddock run failed! Exiting." check mods (if not (null args) && args !! 0 == "all" then False else True) where - - safeHead :: [a] -> Maybe a - safeHead xs = case xs of x : _ -> Just x; [] -> Nothing - wait :: ProcessHandle -> String -> IO () wait h msg = do r <- waitForProcess h -- cgit v1.2.3