[commit: packages/directory] master: Refactor: fmap -> (<$>) (19039f7)
git at git.haskell.org
git at git.haskell.org
Fri Dec 18 09:50:41 UTC 2015
Repository : ssh://git@git.haskell.org/directory
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/19039f71dfaadc4eaa90fbd86e01a540f8ea229a/directory
>---------------------------------------------------------------
commit 19039f71dfaadc4eaa90fbd86e01a540f8ea229a
Author: Phil Ruffwind <rf at rufflewind.com>
Date: Mon May 25 00:36:43 2015 -0400
Refactor: fmap -> (<$>)
>---------------------------------------------------------------
19039f71dfaadc4eaa90fbd86e01a540f8ea229a
System/Directory.hs | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/System/Directory.hs b/System/Directory.hs
index 70882e1..49c8c1e 100644
--- a/System/Directory.hs
+++ b/System/Directory.hs
@@ -80,7 +80,17 @@ module System.Directory
-- * Timestamps
, getModificationTime
+
) where
+#if !MIN_VERSION_base(4, 8, 0)
+import Data.Functor ((<$>))
+#endif
+import Data.Maybe
+ ( listToMaybe
+#ifdef mingw32_HOST_OS
+ , maybeToList
+#endif
+ )
import System.FilePath
import System.IO
@@ -97,8 +107,6 @@ import Foreign.C
{-# CFILES cbits/directory.c #-}
-import Data.Maybe
-
import Data.Time ( UTCTime )
import Data.Time.Clock.POSIX ( posixSecondsToUTCTime )
@@ -402,7 +410,7 @@ createDirectoryIfMissing create_parents path0
#ifdef mingw32_HOST_OS
canIgnore <- (withFileStatus "createDirectoryIfMissing" dir isDirectory)
#else
- canIgnore <- (Posix.isDirectory `fmap` Posix.getFileStatus dir)
+ canIgnore <- (Posix.isDirectory <$> Posix.getFileStatus dir)
#endif
`E.catch` ((\ _ -> return (isAlreadyExistsError e))
:: IOException -> IO Bool)
@@ -424,7 +432,7 @@ getDirectoryType :: FilePath -> IO DirectoryType
getDirectoryType path =
(`ioeSetLocation` "getDirectoryType") `modifyIOError` do
#ifdef mingw32_HOST_OS
- fmap classify (Win32.getFileAttributes path)
+ classify <$> Win32.getFileAttributes path
where fILE_ATTRIBUTE_REPARSE_POINT = 0x400
classify attr
| attr .&. Win32.fILE_ATTRIBUTE_DIRECTORY == 0 = NotDirectory
@@ -791,9 +799,9 @@ foreign import ccall unsafe "realpath"
--
-- /Since: 1.2.2.0/
makeAbsolute :: FilePath -> IO FilePath
-makeAbsolute = fmap normalise . absolutize
+makeAbsolute = (normalise <$>) . absolutize
where absolutize path -- avoid the call to `getCurrentDirectory` if we can
- | isRelative path = fmap (</> path) getCurrentDirectory
+ | isRelative path = (</> path) <$> getCurrentDirectory
| otherwise = return path
-- | 'makeRelative' the current directory.
@@ -1225,8 +1233,8 @@ getXdgDirectory :: XdgDirectory -- ^ which special directory
-- path is returned
-> IO FilePath
getXdgDirectory xdgDir suffix =
- modifyIOError (`ioeSetLocation` "getXdgDirectory") .
- fmap (normalise . (</> suffix)) $
+ modifyIOError (`ioeSetLocation` "getXdgDirectory") $
+ normalise . (</> suffix) <$>
case xdgDir of
XdgData -> get False "XDG_DATA_HOME" ".local/share"
XdgConfig -> get False "XDG_CONFIG_HOME" ".config"
@@ -1243,7 +1251,7 @@ getXdgDirectory xdgDir suffix =
Nothing -> fallback'
Just path | isRelative path -> fallback'
| otherwise -> return path
- where fallback' = fmap (</> fallback) getHomeDirectory
+ where fallback' = (</> fallback) <$> getHomeDirectory
-- | Return the value of an environment variable, or 'Nothing' if there is no
-- such value. (Equivalent to "lookupEnv" from base-4.6.)
More information about the ghc-commits
mailing list