pathtype-0.6: pathtype.cabal
Name: pathtype
Version: 0.6
Synopsis: Type-safe replacement for System.FilePath etc
Description: 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 @'Path' ar fd@ abstract type which
represents file and directory paths. The idea is that there are
two phantom type parameters - the first should be 'Abs' 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.
.
Related packages:
.
* @path@: Provides a wrapper type around 'FilePath'
and maps to functions from @filepath@ package.
This warrants consistency with @filepath@ functions.
Requires Template Haskell.
.
* @data-filepath@:
Requires 'Typeable' and Template Haskell.
Stability: experimental
License: BSD3
Category: System
License-file: LICENSE
Author: Ben Moseley, Ben Millwood, Henning Thielemann
Maintainer: haskell@henning-thielemann.de, ben@moseley.name
HomePage: http://hub.darcs.net/thielema/pathtype/
Build-Type: Simple
Cabal-Version: >=1.8
Extra-Source-Files:
test/TestTemplate.hs
src/System/Path/Internal.hs
directory/pre-1.2/System/Path/ModificationTime.hs
directory/post-incl-1.2/System/Path/ModificationTime.hs
Source-Repository head
Type: darcs
Location: http://hub.darcs.net/thielema/pathtype/
Source-Repository this
Tag: 0.6
Type: darcs
Location: http://hub.darcs.net/thielema/pathtype/
Flag old-time
Description: Build with directory < 1.2 and old-time
Default: True
Flag buildTools
Description: Build tool for updating test module
Default: True
Library
Build-Depends:
QuickCheck >= 2.1.0.1 && < 3,
deepseq >= 1.3 && <1.5,
time >= 1.0 && < 2,
base >= 4 && < 5
If flag(old-time)
Build-Depends: directory >= 1 && < 1.2, old-time >= 1.0 && < 2
Hs-Source-Dirs: directory/pre-1.2
Else
Build-Depends: directory >= 1.2 && < 2
Hs-Source-Dirs: directory/post-incl-1.2
Hs-Source-Dirs: src
Exposed-Modules:
System.Path
System.Path.Directory
System.Path.IO
System.Path.Posix
System.Path.Windows
Other-Modules:
System.Path.ModificationTime
GHC-Options: -Wall -fwarn-tabs -fwarn-incomplete-record-updates -fwarn-unused-do-bind
Test-Suite test
Type: exitcode-stdio-1.0
Main-Is: Test.hs
Other-Modules: TestResult
Hs-Source-Dirs: test
Build-Depends:
pathtype,
random >=1.0 && <1.2,
base
GHC-Options: -Wall -fwarn-tabs -fwarn-incomplete-record-updates -fwarn-unused-do-bind
Executable create-pathtype-test
If flag(buildTools)
Build-Depends:
base
Else
Buildable: True
Main-Is: CreateTest.hs
Hs-Source-Dirs: tool
GHC-Options: -Wall -fwarn-tabs -fwarn-incomplete-record-updates -fwarn-unused-do-bind