Fork chrisdone's path library
I wasn't happy with the way it dealt with Dir vs File things. In his
version of the library, a `Path b Dir` always ends with a trailing
path separator and `Path b File` never ends with a trailing path separator.
IMO, it is nonsensical to make a Dir vs File distinction on path level,
although it first seems nice.
Some of the reasons are:
* a path is just that: a path. It is completely disconnected from IO level
and even if a `Dir`/`File` type theoretically allows us to say "this path
ought to point to a file", there is literally zero guarantee that it will
hold true at runtime. So this basically gives a false feeling of a
type-safe file distinction.
* it's imprecise about Dir vs File distinction, which makes it even worse,
because a directory is also a file (just not a regular file). Add symlinks
to that and the confusion is complete.
* it makes the API oddly complicated for use cases where we basically don't
care (yet) whether something turns out to be a directory or not
Still, it comes also with a few perks:
* it simplifies some functions, because they now have guarantees whether a
path ends in a trailing path separator or not
* it may be safer for interaction with other library functions, which behave
differently depending on a trailing path separator (like probably shelly)
Not limited to, but also in order to fix my remarks without breaking any
benefits, I did:
* rename the `Dir`/`File` types to `TPS`/`NoTPS`, so it's clear we are only
giving information about trailing path separators and not actual file
types we don't know about yet
* add a `MaybeTPS` type, which does not mess with trailing path separators
and also gives no guarantees about them... then added `toNoTPS` and
`toTPS` to allow type-safe conversion
* make some functions accept more general types, so we don't unnecessarily
force paths with trailing separators for `(</>)` for example... instead
these functions now examine the paths to still have correct behavior.
This is really minor overhead. You might say now "but then I can append
filepath to filepath". Well, as I said... we don't know whether it's a
"filepath" at all.
* merge `filename` and `dirname` into `basename` and make `parent` be
`dirname`, so the function names match the name of the POSIX ones,
which do (almost) the same...
* fix a bug in `basename` (formerly `dirname`) which broke the type
guarantees
* add a pattern synonym for easier pattern matching without exporting
the internal Path constructor
2016-03-08 21:53:42 +00:00
|
|
|
name: hpath
|
2018-04-12 00:23:56 +00:00
|
|
|
version: 0.9.2
|
2016-01-28 11:47:15 +00:00
|
|
|
synopsis: Support for well-typed paths
|
2016-05-09 17:06:31 +00:00
|
|
|
description: Support for well-typed paths, utilizing ByteString under the hood.
|
2016-06-03 22:20:41 +00:00
|
|
|
license: BSD3
|
2015-05-07 18:14:23 +00:00
|
|
|
license-file: LICENSE
|
Fork chrisdone's path library
I wasn't happy with the way it dealt with Dir vs File things. In his
version of the library, a `Path b Dir` always ends with a trailing
path separator and `Path b File` never ends with a trailing path separator.
IMO, it is nonsensical to make a Dir vs File distinction on path level,
although it first seems nice.
Some of the reasons are:
* a path is just that: a path. It is completely disconnected from IO level
and even if a `Dir`/`File` type theoretically allows us to say "this path
ought to point to a file", there is literally zero guarantee that it will
hold true at runtime. So this basically gives a false feeling of a
type-safe file distinction.
* it's imprecise about Dir vs File distinction, which makes it even worse,
because a directory is also a file (just not a regular file). Add symlinks
to that and the confusion is complete.
* it makes the API oddly complicated for use cases where we basically don't
care (yet) whether something turns out to be a directory or not
Still, it comes also with a few perks:
* it simplifies some functions, because they now have guarantees whether a
path ends in a trailing path separator or not
* it may be safer for interaction with other library functions, which behave
differently depending on a trailing path separator (like probably shelly)
Not limited to, but also in order to fix my remarks without breaking any
benefits, I did:
* rename the `Dir`/`File` types to `TPS`/`NoTPS`, so it's clear we are only
giving information about trailing path separators and not actual file
types we don't know about yet
* add a `MaybeTPS` type, which does not mess with trailing path separators
and also gives no guarantees about them... then added `toNoTPS` and
`toTPS` to allow type-safe conversion
* make some functions accept more general types, so we don't unnecessarily
force paths with trailing separators for `(</>)` for example... instead
these functions now examine the paths to still have correct behavior.
This is really minor overhead. You might say now "but then I can append
filepath to filepath". Well, as I said... we don't know whether it's a
"filepath" at all.
* merge `filename` and `dirname` into `basename` and make `parent` be
`dirname`, so the function names match the name of the POSIX ones,
which do (almost) the same...
* fix a bug in `basename` (formerly `dirname`) which broke the type
guarantees
* add a pattern synonym for easier pattern matching without exporting
the internal Path constructor
2016-03-08 21:53:42 +00:00
|
|
|
author: Julian Ospald <hasufell@posteo.de>
|
|
|
|
maintainer: Julian Ospald <hasufell@posteo.de>
|
2016-05-09 15:37:33 +00:00
|
|
|
copyright: Julian Ospald 2016
|
2015-05-07 18:14:23 +00:00
|
|
|
category: Filesystem
|
|
|
|
build-type: Simple
|
2018-04-10 23:11:40 +00:00
|
|
|
cabal-version: 1.14
|
2016-05-09 11:31:20 +00:00
|
|
|
extra-source-files: README.md
|
|
|
|
CHANGELOG
|
2016-05-09 16:03:27 +00:00
|
|
|
cbits/dirutils.h
|
|
|
|
doctests-hpath.hs
|
|
|
|
doctests-posix.hs
|
2015-05-07 18:14:23 +00:00
|
|
|
|
|
|
|
library
|
2018-04-11 10:31:11 +00:00
|
|
|
if os(windows)
|
|
|
|
build-depends: unbuildable<0
|
|
|
|
buildable: False
|
2015-05-07 18:14:23 +00:00
|
|
|
hs-source-dirs: src/
|
2016-05-09 11:31:20 +00:00
|
|
|
default-language: Haskell2010
|
2016-06-05 14:16:41 +00:00
|
|
|
if impl(ghc >= 8.0)
|
|
|
|
ghc-options: -Wall -Wno-redundant-constraints
|
|
|
|
else
|
|
|
|
ghc-options: -Wall
|
2016-05-09 11:31:20 +00:00
|
|
|
c-sources: cbits/dirutils.c
|
|
|
|
exposed-modules: HPath,
|
2016-05-09 12:40:30 +00:00
|
|
|
HPath.IO,
|
2016-05-09 14:53:31 +00:00
|
|
|
HPath.IO.Errors,
|
2016-05-09 11:31:20 +00:00
|
|
|
System.Posix.Directory.Foreign,
|
|
|
|
System.Posix.Directory.Traversals,
|
2016-05-18 02:11:40 +00:00
|
|
|
System.Posix.FD,
|
2016-05-09 11:31:20 +00:00
|
|
|
System.Posix.FilePath
|
2016-05-30 11:01:47 +00:00
|
|
|
other-modules: HPath.Internal
|
2018-04-12 00:15:08 +00:00
|
|
|
build-depends: base >= 4.6 && <5
|
2016-06-05 19:52:52 +00:00
|
|
|
, IfElse
|
2018-04-11 23:42:18 +00:00
|
|
|
, bytestring >= 0.10.0.0
|
2016-01-15 01:07:27 +00:00
|
|
|
, deepseq
|
2016-04-16 16:17:44 +00:00
|
|
|
, exceptions
|
|
|
|
, hspec
|
2016-05-24 01:13:36 +00:00
|
|
|
, simple-sendfile >= 0.2.24
|
2016-05-09 11:31:20 +00:00
|
|
|
, unix >= 2.5
|
2016-05-09 14:53:31 +00:00
|
|
|
, unix-bytestring
|
2016-04-16 16:17:44 +00:00
|
|
|
, utf8-string
|
2016-04-04 16:46:25 +00:00
|
|
|
, word8
|
2015-05-07 18:14:23 +00:00
|
|
|
|
2016-04-16 16:17:44 +00:00
|
|
|
|
2016-05-09 11:31:20 +00:00
|
|
|
test-suite doctests-hpath
|
2018-04-11 10:31:11 +00:00
|
|
|
if os(windows)
|
|
|
|
build-depends: unbuildable<0
|
|
|
|
buildable: False
|
2016-05-09 11:31:20 +00:00
|
|
|
default-language: Haskell2010
|
2016-04-16 16:17:44 +00:00
|
|
|
type: exitcode-stdio-1.0
|
|
|
|
ghc-options: -threaded
|
2016-05-09 11:31:20 +00:00
|
|
|
main-is: doctests-hpath.hs
|
2016-04-16 16:17:44 +00:00
|
|
|
build-depends: base
|
|
|
|
, HUnit
|
2016-05-09 11:31:20 +00:00
|
|
|
, QuickCheck
|
2016-04-16 16:17:44 +00:00
|
|
|
, doctest >= 0.8
|
|
|
|
, hpath
|
2016-05-09 11:31:20 +00:00
|
|
|
|
|
|
|
test-suite doctests-posix
|
2018-04-11 10:31:11 +00:00
|
|
|
if os(windows)
|
|
|
|
build-depends: unbuildable<0
|
|
|
|
buildable: False
|
2016-05-09 11:31:20 +00:00
|
|
|
default-language: Haskell2010
|
|
|
|
type: exitcode-stdio-1.0
|
|
|
|
ghc-options: -threaded
|
|
|
|
main-is: doctests-posix.hs
|
|
|
|
build-depends: base,
|
2018-04-11 23:42:18 +00:00
|
|
|
bytestring >= 0.10.0.0,
|
2016-05-09 11:31:20 +00:00
|
|
|
unix,
|
|
|
|
hpath,
|
|
|
|
doctest >= 0.8,
|
|
|
|
HUnit,
|
|
|
|
QuickCheck
|
|
|
|
|
2016-05-09 14:53:31 +00:00
|
|
|
test-suite spec
|
2018-04-11 10:31:11 +00:00
|
|
|
if os(windows)
|
|
|
|
build-depends: unbuildable<0
|
|
|
|
buildable: False
|
2016-05-09 14:53:31 +00:00
|
|
|
Type: exitcode-stdio-1.0
|
|
|
|
Default-Language: Haskell2010
|
|
|
|
Hs-Source-Dirs: test
|
|
|
|
Main-Is: Main.hs
|
|
|
|
other-modules:
|
2018-04-10 23:11:40 +00:00
|
|
|
HPath.IO.AppendFileSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.CanonicalizePathSpec
|
2016-06-05 01:10:28 +00:00
|
|
|
HPath.IO.CopyDirRecursiveCollectFailuresSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.CopyDirRecursiveOverwriteSpec
|
2016-05-29 15:44:00 +00:00
|
|
|
HPath.IO.CopyDirRecursiveSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.CopyFileOverwriteSpec
|
2016-05-29 15:44:00 +00:00
|
|
|
HPath.IO.CopyFileSpec
|
2016-06-12 23:28:55 +00:00
|
|
|
HPath.IO.CreateDirRecursiveSpec
|
2018-04-10 23:11:40 +00:00
|
|
|
HPath.IO.CreateDirSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.CreateRegularFileSpec
|
2016-05-29 15:43:43 +00:00
|
|
|
HPath.IO.CreateSymlinkSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.DeleteDirRecursiveSpec
|
|
|
|
HPath.IO.DeleteDirSpec
|
|
|
|
HPath.IO.DeleteFileSpec
|
|
|
|
HPath.IO.GetDirsFilesSpec
|
|
|
|
HPath.IO.GetFileTypeSpec
|
|
|
|
HPath.IO.MoveFileOverwriteSpec
|
2016-05-29 15:44:00 +00:00
|
|
|
HPath.IO.MoveFileSpec
|
2018-04-10 23:11:40 +00:00
|
|
|
HPath.IO.ReadFileEOFSpec
|
|
|
|
HPath.IO.ReadFileSpec
|
2016-06-05 01:10:28 +00:00
|
|
|
HPath.IO.RecreateSymlinkOverwriteSpec
|
2016-05-29 15:38:27 +00:00
|
|
|
HPath.IO.RecreateSymlinkSpec
|
|
|
|
HPath.IO.RenameFileSpec
|
2018-04-10 23:11:40 +00:00
|
|
|
HPath.IO.ToAbsSpec
|
|
|
|
HPath.IO.WriteFileSpec
|
2016-05-09 14:53:31 +00:00
|
|
|
Spec
|
|
|
|
Utils
|
|
|
|
GHC-Options: -Wall
|
|
|
|
Build-Depends: base
|
|
|
|
, HUnit
|
2016-06-05 19:52:52 +00:00
|
|
|
, IfElse
|
2018-04-11 23:42:18 +00:00
|
|
|
, bytestring >= 0.10.0.0
|
2016-05-09 14:53:31 +00:00
|
|
|
, hpath
|
|
|
|
, hspec >= 1.3
|
|
|
|
, process
|
|
|
|
, unix
|
2016-05-29 15:29:13 +00:00
|
|
|
, unix-bytestring
|
2016-05-09 14:53:31 +00:00
|
|
|
, utf8-string
|
|
|
|
|
2015-05-14 15:47:04 +00:00
|
|
|
source-repository head
|
2016-04-16 16:17:44 +00:00
|
|
|
type: git
|
|
|
|
location: https://github.com/hasufell/hpath
|
|
|
|
|