From 9bd90926e85cde8db67838f5810e10a3a11221ce Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 2 Dec 2021 17:25:15 +0100 Subject: [PATCH] Document relation between joinPath and () Fixes #82 --- Generate.hs | 2 +- System/FilePath/Internal.hs | 1 + System/FilePath/Posix.hs | 1 + System/FilePath/Windows.hs | 1 + tests/TestGen.hs | 2 ++ 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Generate.hs b/Generate.hs index e230676f..6937b2ae 100755 --- a/Generate.hs +++ b/Generate.hs @@ -86,7 +86,7 @@ qualify pw str | otherwise = str where prelude = ["elem","uncurry","snd","fst","not","null","if","then","else" - ,"True","False","Just","Nothing","fromJust","concat","isPrefixOf","isSuffixOf","any"] + ,"True","False","Just","Nothing","fromJust","concat","isPrefixOf","isSuffixOf","any","foldr"] fpops = ["","<.>","-<.>"] diff --git a/System/FilePath/Internal.hs b/System/FilePath/Internal.hs index 8a1e1391..c3dcb863 100644 --- a/System/FilePath/Internal.hs +++ b/System/FilePath/Internal.hs @@ -747,6 +747,7 @@ splitDirectories = map dropTrailingPathSeparator . splitPath -- | Join path elements back together. -- +-- > joinPath a == foldr () "" a -- > joinPath ["/","directory/","file.ext"] == "/directory/file.ext" -- > Valid x => joinPath (splitPath x) == x -- > joinPath [] == "" diff --git a/System/FilePath/Posix.hs b/System/FilePath/Posix.hs index b7e61197..219f7d19 100644 --- a/System/FilePath/Posix.hs +++ b/System/FilePath/Posix.hs @@ -747,6 +747,7 @@ splitDirectories = map dropTrailingPathSeparator . splitPath -- | Join path elements back together. -- +-- > joinPath a == foldr () "" a -- > joinPath ["/","directory/","file.ext"] == "/directory/file.ext" -- > Valid x => joinPath (splitPath x) == x -- > joinPath [] == "" diff --git a/System/FilePath/Windows.hs b/System/FilePath/Windows.hs index 15877020..56aa7197 100644 --- a/System/FilePath/Windows.hs +++ b/System/FilePath/Windows.hs @@ -747,6 +747,7 @@ splitDirectories = map dropTrailingPathSeparator . splitPath -- | Join path elements back together. -- +-- > joinPath a == foldr () "" a -- > joinPath ["/","directory/","file.ext"] == "/directory/file.ext" -- > Valid x => joinPath (splitPath x) == x -- > joinPath [] == "" diff --git a/tests/TestGen.hs b/tests/TestGen.hs index 6364537d..62eb18f4 100755 --- a/tests/TestGen.hs +++ b/tests/TestGen.hs @@ -346,6 +346,8 @@ tests = ,("W.splitDirectories \"C:\\\\test\\\\\\\\\\\\file\" == [\"C:\\\\\", \"test\", \"file\"]", property $ W.splitDirectories "C:\\test\\\\\\file" == ["C:\\", "test", "file"]) ,("P.splitDirectories \"/test///file\" == [\"/\", \"test\", \"file\"]", property $ P.splitDirectories "/test///file" == ["/", "test", "file"]) ,("W.splitDirectories \"/test///file\" == [\"/\", \"test\", \"file\"]", property $ W.splitDirectories "/test///file" == ["/", "test", "file"]) + ,("P.joinPath a == foldr (P.) \"\" a", property $ \a -> P.joinPath a == foldr (P.) "" a) + ,("W.joinPath a == foldr (W.) \"\" a", property $ \a -> W.joinPath a == foldr (W.) "" a) ,("P.joinPath [\"/\", \"directory/\", \"file.ext\"] == \"/directory/file.ext\"", property $ P.joinPath ["/", "directory/", "file.ext"] == "/directory/file.ext") ,("W.joinPath [\"/\", \"directory/\", \"file.ext\"] == \"/directory/file.ext\"", property $ W.joinPath ["/", "directory/", "file.ext"] == "/directory/file.ext") ,("P.joinPath (P.splitPath x) == x", property $ \(QFilePathValidP x) -> P.joinPath (P.splitPath x) == x)