[commit: packages/filepath] master: #49, change to use </> in all the docs (93ad049)
git at git.haskell.org
git at git.haskell.org
Mon Dec 28 20:39:50 UTC 2015
Repository : ssh://git@git.haskell.org/filepath
On branch : master
Link : http://git.haskell.org/packages/filepath.git/commitdiff/93ad049a7e095b5b7e6c622eaab5ce9ede4682c9
>---------------------------------------------------------------
commit 93ad049a7e095b5b7e6c622eaab5ce9ede4682c9
Author: Neil Mitchell <ndmitchell at gmail.com>
Date: Tue Dec 22 08:19:47 2015 +0000
#49, change to use </> in all the docs
>---------------------------------------------------------------
93ad049a7e095b5b7e6c622eaab5ce9ede4682c9
System/FilePath/Internal.hs | 32 ++++++++++++++++----------------
tests/TestGen.hs | 30 ++++++++++++++++--------------
2 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs
index fa0b521..abb4e97 100644
--- a/System/FilePath/Internal.hs
+++ b/System/FilePath/Internal.hs
@@ -461,7 +461,7 @@ isDrive x = not (null x) && null (dropDrive x)
---------------------------------------------------------------------
-- Operations on a filepath, as a list of directories
--- | Split a filename into directory and file. 'combine' is the inverse.
+-- | Split a filename into directory and file. '</>' is the inverse.
-- The first component will often end with a trailing slash.
--
-- > splitFileName "/directory/file.ext" == ("/directory/","file.ext")
@@ -624,39 +624,39 @@ combineAlways a b | null a = b
-- > Posix: "/directory" </> "file.ext" == "/directory/file.ext"
-- > Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
-- > "directory" </> "/file.ext" == "/file.ext"
--- > Valid x => combine (takeDirectory x) (takeFileName x) `equalFilePath` x
+-- > Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x
--
-- Combined:
--
--- > Posix: combine "/" "test" == "/test"
--- > Posix: combine "home" "bob" == "home/bob"
--- > Posix: combine "x:" "foo" == "x:/foo"
--- > Windows: combine "C:\\foo" "bar" == "C:\\foo\\bar"
--- > Windows: combine "home" "bob" == "home\\bob"
+-- > Posix: "/" </> "test" == "/test"
+-- > Posix: "home" </> "bob" == "home/bob"
+-- > Posix: "x:" </> "foo" == "x:/foo"
+-- > Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar"
+-- > Windows: "home" </> "bob" == "home\\bob"
--
-- Not combined:
--
--- > Posix: combine "home" "/bob" == "/bob"
--- > Windows: combine "home" "C:\\bob" == "C:\\bob"
+-- > Posix: "home" </> "/bob" == "/bob"
+-- > Windows: "home" </> "C:\\bob" == "C:\\bob"
--
-- Not combined (tricky):
--
-- On Windows, if a filepath starts with a single slash, it is relative to the
-- root of the current drive. In [1], this is (confusingly) referred to as an
-- absolute path.
--- The current behavior of @combine@ is to never combine these forms.
+-- The current behavior of @</>@ is to never combine these forms.
--
--- > Windows: combine "home" "/bob" == "/bob"
--- > Windows: combine "home" "\\bob" == "\\bob"
--- > Windows: combine "C:\\home" "\\bob" == "\\bob"
+-- > Windows: "home" </> "/bob" == "/bob"
+-- > Windows: "home" </> "\\bob" == "\\bob"
+-- > Windows: "C:\\home" </> "\\bob" == "\\bob"
--
-- On Windows, from [1]: "If a file name begins with only a disk designator
-- but not the backslash after the colon, it is interpreted as a relative path
-- to the current directory on the drive with the specified letter."
--- The current behavior of @combine@ is to never combine these forms.
+-- The current behavior of @</>@ is to never combine these forms.
--
--- > Windows: combine "D:\\foo" "C:bar" == "C:bar"
--- > Windows: combine "C:\\foo" "C:bar" == "C:bar"
+-- > Windows: "D:\\foo" </> "C:bar" == "C:bar"
+-- > Windows: "C:\\foo" </> "C:bar" == "C:bar"
(</>) :: FilePath -> FilePath -> FilePath
(</>) = combine
diff --git a/tests/TestGen.hs b/tests/TestGen.hs
index 9bb3ebe..7dfaffc 100755
--- a/tests/TestGen.hs
+++ b/tests/TestGen.hs
@@ -265,22 +265,24 @@ tests =
,("W.replaceDirectory \"root/file.ext\" \"/directory/\" == \"/directory/file.ext\"", test $ W.replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext")
,("P.replaceDirectory x (P.takeDirectory x) `P.equalFilePath` x", test $ \(QFilePathValidP x) -> P.replaceDirectory x (P.takeDirectory x) `P.equalFilePath` x)
,("W.replaceDirectory x (W.takeDirectory x) `W.equalFilePath` x", test $ \(QFilePathValidW x) -> W.replaceDirectory x (W.takeDirectory x) `W.equalFilePath` x)
- ,("P.combine (P.takeDirectory x) (P.takeFileName x) `P.equalFilePath` x", test $ \(QFilePathValidP x) -> P.combine (P.takeDirectory x) (P.takeFileName x) `P.equalFilePath` x)
- ,("W.combine (W.takeDirectory x) (W.takeFileName x) `W.equalFilePath` x", test $ \(QFilePathValidW x) -> W.combine (W.takeDirectory x) (W.takeFileName x) `W.equalFilePath` x)
- ,("P.combine \"/\" \"test\" == \"/test\"", test $ P.combine "/" "test" == "/test")
- ,("P.combine \"home\" \"bob\" == \"home/bob\"", test $ P.combine "home" "bob" == "home/bob")
- ,("P.combine \"x:\" \"foo\" == \"x:/foo\"", test $ P.combine "x:" "foo" == "x:/foo")
- ,("W.combine \"C:\\\\foo\" \"bar\" == \"C:\\\\foo\\\\bar\"", test $ W.combine "C:\\foo" "bar" == "C:\\foo\\bar")
- ,("W.combine \"home\" \"bob\" == \"home\\\\bob\"", test $ W.combine "home" "bob" == "home\\bob")
- ,("P.combine \"home\" \"/bob\" == \"/bob\"", test $ P.combine "home" "/bob" == "/bob")
- ,("W.combine \"home\" \"C:\\\\bob\" == \"C:\\\\bob\"", test $ W.combine "home" "C:\\bob" == "C:\\bob")
- ,("W.combine \"home\" \"/bob\" == \"/bob\"", test $ W.combine "home" "/bob" == "/bob")
- ,("W.combine \"home\" \"\\\\bob\" == \"\\\\bob\"", test $ W.combine "home" "\\bob" == "\\bob")
- ,("W.combine \"C:\\\\home\" \"\\\\bob\" == \"\\\\bob\"", test $ W.combine "C:\\home" "\\bob" == "\\bob")
- ,("W.combine \"D:\\\\foo\" \"C:bar\" == \"C:bar\"", test $ W.combine "D:\\foo" "C:bar" == "C:bar")
- ,("W.combine \"C:\\\\foo\" \"C:bar\" == \"C:bar\"", test $ W.combine "C:\\foo" "C:bar" == "C:bar")
,("\"/directory\" P.</> \"file.ext\" == \"/directory/file.ext\"", test $ "/directory" P.</> "file.ext" == "/directory/file.ext")
,("\"/directory\" W.</> \"file.ext\" == \"/directory\\\\file.ext\"", test $ "/directory" W.</> "file.ext" == "/directory\\file.ext")
+ ,("\"directory\" P.</> \"/file.ext\" == \"/file.ext\"", test $ "directory" P.</> "/file.ext" == "/file.ext")
+ ,("\"directory\" W.</> \"/file.ext\" == \"/file.ext\"", test $ "directory" W.</> "/file.ext" == "/file.ext")
+ ,("(P.takeDirectory x P.</> P.takeFileName x) `P.equalFilePath` x", test $ \(QFilePathValidP x) -> (P.takeDirectory x P.</> P.takeFileName x) `P.equalFilePath` x)
+ ,("(W.takeDirectory x W.</> W.takeFileName x) `W.equalFilePath` x", test $ \(QFilePathValidW x) -> (W.takeDirectory x W.</> W.takeFileName x) `W.equalFilePath` x)
+ ,("\"/\" P.</> \"test\" == \"/test\"", test $ "/" P.</> "test" == "/test")
+ ,("\"home\" P.</> \"bob\" == \"home/bob\"", test $ "home" P.</> "bob" == "home/bob")
+ ,("\"x:\" P.</> \"foo\" == \"x:/foo\"", test $ "x:" P.</> "foo" == "x:/foo")
+ ,("\"C:\\\\foo\" W.</> \"bar\" == \"C:\\\\foo\\\\bar\"", test $ "C:\\foo" W.</> "bar" == "C:\\foo\\bar")
+ ,("\"home\" W.</> \"bob\" == \"home\\\\bob\"", test $ "home" W.</> "bob" == "home\\bob")
+ ,("\"home\" P.</> \"/bob\" == \"/bob\"", test $ "home" P.</> "/bob" == "/bob")
+ ,("\"home\" W.</> \"C:\\\\bob\" == \"C:\\\\bob\"", test $ "home" W.</> "C:\\bob" == "C:\\bob")
+ ,("\"home\" W.</> \"/bob\" == \"/bob\"", test $ "home" W.</> "/bob" == "/bob")
+ ,("\"home\" W.</> \"\\\\bob\" == \"\\\\bob\"", test $ "home" W.</> "\\bob" == "\\bob")
+ ,("\"C:\\\\home\" W.</> \"\\\\bob\" == \"\\\\bob\"", test $ "C:\\home" W.</> "\\bob" == "\\bob")
+ ,("\"D:\\\\foo\" W.</> \"C:bar\" == \"C:bar\"", test $ "D:\\foo" W.</> "C:bar" == "C:bar")
+ ,("\"C:\\\\foo\" W.</> \"C:bar\" == \"C:bar\"", test $ "C:\\foo" W.</> "C:bar" == "C:bar")
,("P.splitPath \"/directory/file.ext\" == [\"/\", \"directory/\", \"file.ext\"]", test $ P.splitPath "/directory/file.ext" == ["/", "directory/", "file.ext"])
,("W.splitPath \"/directory/file.ext\" == [\"/\", \"directory/\", \"file.ext\"]", test $ W.splitPath "/directory/file.ext" == ["/", "directory/", "file.ext"])
,("concat (P.splitPath x) == x", test $ \(QFilePath x) -> concat (P.splitPath x) == x)
More information about the ghc-commits
mailing list