summaryrefslogtreecommitdiff
path: root/Utility.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-15 02:49:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-15 03:38:08 -0400
commitcad0e1c8b7eb21f8dceca8dd9fa3bc1d1aa7eabd (patch)
treeb6be12dc1cc83a35ca7d89a862d85e6d71c38572 /Utility.hs
parentefa7f544050c0d5be6bc1b0fc0125278e475c213 (diff)
simplified a bunch of Maybe handling
Diffstat (limited to 'Utility.hs')
-rw-r--r--Utility.hs11
1 files changed, 4 insertions, 7 deletions
diff --git a/Utility.hs b/Utility.hs
index 0dab37104..44c8cdd65 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -165,9 +165,7 @@ prop_parentDir_basics dir
dirContains :: FilePath -> FilePath -> Bool
dirContains a b = a == b || a' == b' || (a'++"/") `isPrefixOf` b'
where
- norm p = case (absNormPath p ".") of
- Just r -> r
- Nothing -> ""
+ norm p = maybe "" id $ absNormPath p "."
a' = norm a
b' = norm b
@@ -180,10 +178,9 @@ absPath file = do
{- Converts a filename into a normalized, absolute path
- from the specified cwd. -}
absPathFrom :: FilePath -> FilePath -> FilePath
-absPathFrom cwd file =
- case absNormPath cwd file of
- Just f -> f
- Nothing -> error $ "unable to normalize " ++ file
+absPathFrom cwd file = maybe bad id $ absNormPath cwd file
+ where
+ bad = error $ "unable to normalize " ++ file
{- Constructs a relative path from the CWD to a file.
-