filepath

Library for manipulating FilePaths in a cross platform way.

http://www-users.cs.york.ac.uk/~ndm/filepath/

Version on this page:1.3.0.2
LTS Haskell 22.14:1.4.200.1
Stackage Nightly 2024-03-28:1.4.200.1
Latest on Hackage:1.5.2.0

See all snapshots filepath appears in

BSD-3-Clause licensed by Neil Mitchell
Maintained by [email protected]
This version can be pinned in stack with:filepath-1.3.0.2@sha256:0302f2911180004fed296c9a1320ab8e8a0b27f48e32e5f5ee72648898d04813,2017

Module documentation for 1.3.0.2

System.FilePath Build Status

I have written a System.FilePath module in part based on the one in Yhc, and in part based on the one in Cabal (thanks to Lemmih). The aim is to try and get this module into the base package, as FilePaths are something many programs use, but its all too easy to hack up a little function that gets it right most of the time on most platforms, and there lies a source of bugs.

This module is Posix (Linux) and Windows capable - just import System.FilePath and it will pick the right one. Of course, if you demand Windows paths on all OSes, then System.FilePath.Windows will give you that (same with Posix). Written in Haskell 98 with Hierarchical Modules.

If you go to the Haddock page, there are a few little examples at the top of the re-exported module.

Acknowledgments

Thanks to Marc Webber, shapr, David House, Lemmih, others…

Competitors

System.FilePath from Cabal, by Lemmih FilePath.hs and NameManip.hs from MissingH

The one from Cabal and FilePath.hs in MissingH are both very similar, I stole lots of good ideas from those two.

NameManip.hs seems to be more unix specific, but all functions in that module have equivalents in this new System.FilePath module.

Hopefully this new module can be used without noticing any lost functions, and certainly adds new features/functions to the table.

Should FilePath be an abstract data type?

The answer for this library is no. This is a deliberate design decision.

In Haskell 98 the definition is type FilePath = String, and all functions operating on FilePaths, i.e. readFile/writeFile etc take FilePaths. The only way to introduce an abstract type is to provide wrappers for these functions or casts between Strings and FilePathAbstracts.

There are also additional questions as to what constitutes a FilePath, and what is just a pure String. For example, “/path/file.ext” is a FilePath. Is “/” ? “/path” ? “path” ? “file.ext” ? “.ext” ? “file” ?

With that being accepted, it should be trivial to write System.FilePath.ByteString which has the same interface as System.FilePath yet operates on ByteStrings.

Changes

Changelog for filepath package

1.3.0.2 Mar 2014

  • Bundled with GHC 7.8.1

  • Update to Cabal 1.10 format

  • Minor Haddock cleanups

1.3.0.1 Sep 2012

  • Bundled with GHC 7.6.1

  • No changes

1.3.0.0 Feb 2012

  • Bundled with GHC 7.4.1

  • Add support for SafeHaskell

  • Fix normalise "/" to result in "/" rather than "/."