Skip to content
Snippets Groups Projects
Verified Commit 2a8e94a7 authored by Julian Ospald's avatar Julian Ospald :tea:
Browse files

Add top-level documentation to System.FilePath as well

parent b0353a1e
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,49 @@ depending on the platform.
Both "System.FilePath.Posix" and "System.FilePath.Windows" provide the
same interface.
Given the example 'FilePath': @\/directory\/file.ext@
We can use the following functions to extract pieces.
* 'takeFileName' gives @\"file.ext\"@
* 'takeDirectory' gives @\"\/directory\"@
* 'takeExtension' gives @\".ext\"@
* 'dropExtension' gives @\"\/directory\/file\"@
* 'takeBaseName' gives @\"file\"@
And we could have built an equivalent path with the following expressions:
* @\"\/directory\" '</>' \"file.ext\"@.
* @\"\/directory\/file" '<.>' \"ext\"@.
* @\"\/directory\/file.txt" '-<.>' \"ext\"@.
Each function in this module is documented with several examples,
which are also used as tests.
Here are a few examples of using the @filepath@ functions together:
/Example 1:/ Find the possible locations of a Haskell module @Test@ imported from module @Main@:
@['replaceFileName' path_to_main \"Test\" '<.>' ext | ext <- [\"hs\",\"lhs\"] ]@
/Example 2:/ Download a file from @url@ and save it to disk:
@do let file = 'makeValid' url
System.Directory.createDirectoryIfMissing True ('takeDirectory' file)@
/Example 3:/ Compile a Haskell file, putting the @.hi@ file under @interface@:
@'takeDirectory' file '</>' \"interface\" '</>' ('takeFileName' file '-<.>' \"hi\")@
References:
[1] <http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx Naming Files, Paths and Namespaces> (Microsoft MSDN)
-}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment