Skip to content

Commit 93ad049

Browse files
committed
#49, change to use </> in all the docs
1 parent df048ab commit 93ad049

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

System/FilePath/Internal.hs

+16-16
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ isDrive x = not (null x) && null (dropDrive x)
461461
---------------------------------------------------------------------
462462
-- Operations on a filepath, as a list of directories
463463

464-
-- | Split a filename into directory and file. 'combine' is the inverse.
464+
-- | Split a filename into directory and file. '</>' is the inverse.
465465
-- The first component will often end with a trailing slash.
466466
--
467467
-- > splitFileName "/directory/file.ext" == ("/directory/","file.ext")
@@ -624,39 +624,39 @@ combineAlways a b | null a = b
624624
-- > Posix: "/directory" </> "file.ext" == "/directory/file.ext"
625625
-- > Windows: "/directory" </> "file.ext" == "/directory\\file.ext"
626626
-- > "directory" </> "/file.ext" == "/file.ext"
627-
-- > Valid x => combine (takeDirectory x) (takeFileName x) `equalFilePath` x
627+
-- > Valid x => (takeDirectory x </> takeFileName x) `equalFilePath` x
628628
--
629629
-- Combined:
630630
--
631-
-- > Posix: combine "/" "test" == "/test"
632-
-- > Posix: combine "home" "bob" == "home/bob"
633-
-- > Posix: combine "x:" "foo" == "x:/foo"
634-
-- > Windows: combine "C:\\foo" "bar" == "C:\\foo\\bar"
635-
-- > Windows: combine "home" "bob" == "home\\bob"
631+
-- > Posix: "/" </> "test" == "/test"
632+
-- > Posix: "home" </> "bob" == "home/bob"
633+
-- > Posix: "x:" </> "foo" == "x:/foo"
634+
-- > Windows: "C:\\foo" </> "bar" == "C:\\foo\\bar"
635+
-- > Windows: "home" </> "bob" == "home\\bob"
636636
--
637637
-- Not combined:
638638
--
639-
-- > Posix: combine "home" "/bob" == "/bob"
640-
-- > Windows: combine "home" "C:\\bob" == "C:\\bob"
639+
-- > Posix: "home" </> "/bob" == "/bob"
640+
-- > Windows: "home" </> "C:\\bob" == "C:\\bob"
641641
--
642642
-- Not combined (tricky):
643643
--
644644
-- On Windows, if a filepath starts with a single slash, it is relative to the
645645
-- root of the current drive. In [1], this is (confusingly) referred to as an
646646
-- absolute path.
647-
-- The current behavior of @combine@ is to never combine these forms.
647+
-- The current behavior of @</>@ is to never combine these forms.
648648
--
649-
-- > Windows: combine "home" "/bob" == "/bob"
650-
-- > Windows: combine "home" "\\bob" == "\\bob"
651-
-- > Windows: combine "C:\\home" "\\bob" == "\\bob"
649+
-- > Windows: "home" </> "/bob" == "/bob"
650+
-- > Windows: "home" </> "\\bob" == "\\bob"
651+
-- > Windows: "C:\\home" </> "\\bob" == "\\bob"
652652
--
653653
-- On Windows, from [1]: "If a file name begins with only a disk designator
654654
-- but not the backslash after the colon, it is interpreted as a relative path
655655
-- to the current directory on the drive with the specified letter."
656-
-- The current behavior of @combine@ is to never combine these forms.
656+
-- The current behavior of @</>@ is to never combine these forms.
657657
--
658-
-- > Windows: combine "D:\\foo" "C:bar" == "C:bar"
659-
-- > Windows: combine "C:\\foo" "C:bar" == "C:bar"
658+
-- > Windows: "D:\\foo" </> "C:bar" == "C:bar"
659+
-- > Windows: "C:\\foo" </> "C:bar" == "C:bar"
660660
(</>) :: FilePath -> FilePath -> FilePath
661661
(</>) = combine
662662

tests/TestGen.hs

+16-14
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,24 @@ tests =
265265
,("W.replaceDirectory \"root/file.ext\" \"/directory/\" == \"/directory/file.ext\"", test $ W.replaceDirectory "root/file.ext" "/directory/" == "/directory/file.ext")
266266
,("P.replaceDirectory x (P.takeDirectory x) `P.equalFilePath` x", test $ \(QFilePathValidP x) -> P.replaceDirectory x (P.takeDirectory x) `P.equalFilePath` x)
267267
,("W.replaceDirectory x (W.takeDirectory x) `W.equalFilePath` x", test $ \(QFilePathValidW x) -> W.replaceDirectory x (W.takeDirectory x) `W.equalFilePath` x)
268-
,("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)
269-
,("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)
270-
,("P.combine \"/\" \"test\" == \"/test\"", test $ P.combine "/" "test" == "/test")
271-
,("P.combine \"home\" \"bob\" == \"home/bob\"", test $ P.combine "home" "bob" == "home/bob")
272-
,("P.combine \"x:\" \"foo\" == \"x:/foo\"", test $ P.combine "x:" "foo" == "x:/foo")
273-
,("W.combine \"C:\\\\foo\" \"bar\" == \"C:\\\\foo\\\\bar\"", test $ W.combine "C:\\foo" "bar" == "C:\\foo\\bar")
274-
,("W.combine \"home\" \"bob\" == \"home\\\\bob\"", test $ W.combine "home" "bob" == "home\\bob")
275-
,("P.combine \"home\" \"/bob\" == \"/bob\"", test $ P.combine "home" "/bob" == "/bob")
276-
,("W.combine \"home\" \"C:\\\\bob\" == \"C:\\\\bob\"", test $ W.combine "home" "C:\\bob" == "C:\\bob")
277-
,("W.combine \"home\" \"/bob\" == \"/bob\"", test $ W.combine "home" "/bob" == "/bob")
278-
,("W.combine \"home\" \"\\\\bob\" == \"\\\\bob\"", test $ W.combine "home" "\\bob" == "\\bob")
279-
,("W.combine \"C:\\\\home\" \"\\\\bob\" == \"\\\\bob\"", test $ W.combine "C:\\home" "\\bob" == "\\bob")
280-
,("W.combine \"D:\\\\foo\" \"C:bar\" == \"C:bar\"", test $ W.combine "D:\\foo" "C:bar" == "C:bar")
281-
,("W.combine \"C:\\\\foo\" \"C:bar\" == \"C:bar\"", test $ W.combine "C:\\foo" "C:bar" == "C:bar")
282268
,("\"/directory\" P.</> \"file.ext\" == \"/directory/file.ext\"", test $ "/directory" P.</> "file.ext" == "/directory/file.ext")
283269
,("\"/directory\" W.</> \"file.ext\" == \"/directory\\\\file.ext\"", test $ "/directory" W.</> "file.ext" == "/directory\\file.ext")
270+
,("\"directory\" P.</> \"/file.ext\" == \"/file.ext\"", test $ "directory" P.</> "/file.ext" == "/file.ext")
271+
,("\"directory\" W.</> \"/file.ext\" == \"/file.ext\"", test $ "directory" W.</> "/file.ext" == "/file.ext")
272+
,("(P.takeDirectory x P.</> P.takeFileName x) `P.equalFilePath` x", test $ \(QFilePathValidP x) -> (P.takeDirectory x P.</> P.takeFileName x) `P.equalFilePath` x)
273+
,("(W.takeDirectory x W.</> W.takeFileName x) `W.equalFilePath` x", test $ \(QFilePathValidW x) -> (W.takeDirectory x W.</> W.takeFileName x) `W.equalFilePath` x)
274+
,("\"/\" P.</> \"test\" == \"/test\"", test $ "/" P.</> "test" == "/test")
275+
,("\"home\" P.</> \"bob\" == \"home/bob\"", test $ "home" P.</> "bob" == "home/bob")
276+
,("\"x:\" P.</> \"foo\" == \"x:/foo\"", test $ "x:" P.</> "foo" == "x:/foo")
277+
,("\"C:\\\\foo\" W.</> \"bar\" == \"C:\\\\foo\\\\bar\"", test $ "C:\\foo" W.</> "bar" == "C:\\foo\\bar")
278+
,("\"home\" W.</> \"bob\" == \"home\\\\bob\"", test $ "home" W.</> "bob" == "home\\bob")
279+
,("\"home\" P.</> \"/bob\" == \"/bob\"", test $ "home" P.</> "/bob" == "/bob")
280+
,("\"home\" W.</> \"C:\\\\bob\" == \"C:\\\\bob\"", test $ "home" W.</> "C:\\bob" == "C:\\bob")
281+
,("\"home\" W.</> \"/bob\" == \"/bob\"", test $ "home" W.</> "/bob" == "/bob")
282+
,("\"home\" W.</> \"\\\\bob\" == \"\\\\bob\"", test $ "home" W.</> "\\bob" == "\\bob")
283+
,("\"C:\\\\home\" W.</> \"\\\\bob\" == \"\\\\bob\"", test $ "C:\\home" W.</> "\\bob" == "\\bob")
284+
,("\"D:\\\\foo\" W.</> \"C:bar\" == \"C:bar\"", test $ "D:\\foo" W.</> "C:bar" == "C:bar")
285+
,("\"C:\\\\foo\" W.</> \"C:bar\" == \"C:bar\"", test $ "C:\\foo" W.</> "C:bar" == "C:bar")
284286
,("P.splitPath \"/directory/file.ext\" == [\"/\", \"directory/\", \"file.ext\"]", test $ P.splitPath "/directory/file.ext" == ["/", "directory/", "file.ext"])
285287
,("W.splitPath \"/directory/file.ext\" == [\"/\", \"directory/\", \"file.ext\"]", test $ W.splitPath "/directory/file.ext" == ["/", "directory/", "file.ext"])
286288
,("concat (P.splitPath x) == x", test $ \(QFilePath x) -> concat (P.splitPath x) == x)

0 commit comments

Comments
 (0)