pathtype: Type-safe replacement for System.FilePath etc
This package provides type-safe access to filepath manipulations.
System.Path is designed to be used instead of System.FilePath. (It is intended to provide versions of functions from that module which have equivalent functionality but are more typesafe). System.Path.Directory is a companion module providing a type-safe alternative to System.Directory.
The heart of this module is the
abstract type which
represents file and directory paths. The idea is that there are
two phantom type parameters - the first should be Path
ar fdAbs
or Rel
,
and the second File
or Dir
. A number of type synonyms are
provided for common types:
type AbsFile = Path Abs File type RelFile = Path Rel File type AbsDir = Path Abs Dir type RelDir = Path Rel Dir type AbsPath fd = Path Abs fd type RelPath fd = Path Rel fd type FilePath ar = Path ar File type DirPath ar = Path ar Dir
The type of the combine
(aka </>
) function gives the idea:
(</>) :: DirPath ar -> RelPath fd -> Path ar fd
Together this enables us to give more meaningful types to a lot of the functions, and (hopefully) catch a bunch more errors at compile time.
Overloaded string literals are supported, so with the OverloadedStrings
extension enabled, you can:
f :: FilePath ar f = "tmp" </> "someFile" <.> "ext"
If you don't want to use OverloadedStrings
, you can use the construction fns:
f :: FilePath ar f = asDirPath "tmp" </> asFilePath "someFile" <.> "ext"
or...
f :: FilePath ar f = asPath "tmp" </> asPath "someFile" <.> "ext"
or just...
f :: FilePath ar f = asPath "tmp/someFile.ext"
One point to note is that whether one of these is interpreted as an absolute or a relative path depends on the type at which it is used:
*System.Path> f :: AbsFile /tmp/someFile.ext *System.Path> f :: RelFile tmp/someFile.ext
You will typically want to import as follows:
import Prelude hiding (FilePath) import System.Path import System.Path.Directory import System.Path.IO
The basic API (and properties satisfied) are heavily influenced by Neil Mitchell's System.FilePath module.
Modules
[Index]
Flags
Automatic Flags
Name | Description | Default |
---|---|---|
old-time | Build with directory < 1.2 and old-time | Enabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- pathtype-0.5.4.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.0.1, 0.0.2, 0.0.3, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.5.4.1, 0.5.4.2, 0.5.4.3, 0.5.5, 0.6, 0.7, 0.7.0.1, 0.8, 0.8.1, 0.8.1.1, 0.8.1.2, 0.8.1.3 |
---|---|
Dependencies | base (>=4 && <5), directory (>=1 && <2), old-time (>=1.0 && <2), QuickCheck (>=2.1.0.1 && <3), time (>=1.0 && <2) [details] |
License | BSD-3-Clause |
Author | Ben Moseley, Ben Millwood |
Maintainer | ben@moseley.name |
Category | System |
Home page | http://code.haskell.org/pathtype |
Source repo | head: git clone https://github.com/benmos/pathtype |
Uploaded | by HenningThielemann at 2015-10-06T19:58:52Z |
Distributions | LTSHaskell:0.8.1.3, NixOS:0.8.1.3, Stackage:0.8.1.3 |
Reverse Dependencies | 5 direct, 18 indirect [details] |
Downloads | 15105 total (3 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2015-10-06 [all 1 reports] |