[commit: packages/filepath] master: #49, move the docs from combine to </>, which is the one most people use (a5518ec)

git at git.haskell.org git at git.haskell.org
Mon Dec 28 20:39:44 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/a5518ec65e8894d4c34371e59a801490fd3c179f

>---------------------------------------------------------------

commit a5518ec65e8894d4c34371e59a801490fd3c179f
Author: Neil Mitchell <ndmitchell at gmail.com>
Date:   Tue Dec 22 08:10:35 2015 +0000

    #49, move the docs from combine to </>, which is the one most people use


>---------------------------------------------------------------

a5518ec65e8894d4c34371e59a801490fd3c179f
 System/FilePath/Internal.hs | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index c67b0eb..eb27e03 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -603,8 +603,23 @@ replaceDirectory :: FilePath -> String -> FilePath
 replaceDirectory x dir = combineAlways dir (takeFileName x)
 
 
--- | Combine two paths, if the second path starts with a path separator or a
---   drive letter, then it returns the second.
+-- | An alias for '</>'.
+combine :: FilePath -> FilePath -> FilePath
+combine a b | hasLeadingPathSeparator b || hasDrive b = b
+            | otherwise = combineAlways a b
+
+-- | Combine two paths, assuming rhs is NOT absolute.
+combineAlways :: FilePath -> FilePath -> FilePath
+combineAlways a b | null a = b
+                  | null b = a
+                  | hasTrailingPathSeparator a = a ++ b
+                  | otherwise = case a of
+                      [a1,':'] | isWindows && isLetter a1 -> a ++ b
+                      _ -> a ++ [pathSeparator] ++ b
+
+
+-- | Combine two paths with a path separator.
+--   If the second path starts with a path separator or a drive letter, then it returns the second.
 --
 -- > Posix:   "/directory" </> "file.ext" == "/directory/file.ext"
 -- > Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
@@ -641,21 +656,6 @@ replaceDirectory x dir = combineAlways dir (takeFileName x)
 --
 -- > Windows: combine "D:\\foo" "C:bar" == "C:bar"
 -- > Windows: combine "C:\\foo" "C:bar" == "C:bar"
-combine :: FilePath -> FilePath -> FilePath
-combine a b | hasLeadingPathSeparator b || hasDrive b = b
-            | otherwise = combineAlways a b
-
--- | Combine two paths, assuming rhs is NOT absolute.
-combineAlways :: FilePath -> FilePath -> FilePath
-combineAlways a b | null a = b
-                  | null b = a
-                  | hasTrailingPathSeparator a = a ++ b
-                  | otherwise = case a of
-                      [a1,':'] | isWindows && isLetter a1 -> a ++ b
-                      _ -> a ++ [pathSeparator] ++ b
-
-
--- | Join two values with a path separator. For examples and caveats see the equivalent function 'combine'.
 (</>) :: FilePath -> FilePath -> FilePath
 (</>) = combine
 



More information about the ghc-commits mailing list