Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Path s b t
- = RelDir (Path Rel Dir) RelPathPrefix
- | RelFile (Path Rel File) RelPathPrefix
- | AbsDir (Path Abs Dir)
- | AbsFile (Path Abs File)
- | RelDirW (Path Rel Dir) RelPathPrefix
- | RelFileW (Path Rel File) RelPathPrefix
- | AbsDirW (Path Abs Dir)
- | AbsFileW (Path Abs File)
- | RelDirP (Path Rel Dir) RelPathPrefix
- | RelFileP (Path Rel File) RelPathPrefix
- | AbsDirP (Path Abs Dir)
- | AbsFileP (Path Abs File)
- data RelPathPrefix
- data Abs
- data Rel dir
- data Dir dir
- data File file
- data Posix
- data Windows
- data System
- type Path' = Path System
- type Rel' = Rel ()
- type Dir' = Dir ()
- type File' = File ()
- parseRelFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d) t) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d) t)
- extractRelPathPrefix :: [Char] -> FilePath -> (RelPathPrefix, FilePath)
- prefixNumParentDirs :: RelPathPrefix -> Int
- relPathNumParentDirs :: Path s (Rel r) t -> Int
- relPathPrefix :: Path s (Rel r) t -> RelPathPrefix
- impossible :: a
Documentation
Strongly typed file path. Central type of the StrongPath.
s
- Standard: Posix or windows. Can be fixed (
Posix
,Windows
) or determined by the system (System
). b
- Base: Absolute (
Abs
) or relative (Rel
). t
- Type: File (
File
) or directory (Dir
).
Some examples:
Path System (Dir HomeDir) (File FooFile) Path System Abs (Dir HomeDir) Path Posix (Rel ProjectRoot) (File ())
RelDir (Path Rel Dir) RelPathPrefix | |
RelFile (Path Rel File) RelPathPrefix | |
AbsDir (Path Abs Dir) | |
AbsFile (Path Abs File) | |
RelDirW (Path Rel Dir) RelPathPrefix | |
RelFileW (Path Rel File) RelPathPrefix | |
AbsDirW (Path Abs Dir) | |
AbsFileW (Path Abs File) | |
RelDirP (Path Rel Dir) RelPathPrefix | |
RelFileP (Path Rel File) RelPathPrefix | |
AbsDirP (Path Abs Dir) | |
AbsFileP (Path Abs File) |
data RelPathPrefix Source #
Instances
Eq RelPathPrefix Source # | |
Defined in StrongPath.Internal (==) :: RelPathPrefix -> RelPathPrefix -> Bool # (/=) :: RelPathPrefix -> RelPathPrefix -> Bool # | |
Show RelPathPrefix Source # | |
Defined in StrongPath.Internal showsPrec :: Int -> RelPathPrefix -> ShowS # show :: RelPathPrefix -> String # showList :: [RelPathPrefix] -> ShowS # | |
Lift RelPathPrefix Source # | |
Defined in StrongPath.Internal lift :: RelPathPrefix -> Q Exp # liftTyped :: RelPathPrefix -> Q (TExp RelPathPrefix) # |
Describes Path
base as absolute.
Describes Path
base as relative to the directory dir
.
Means that path points to a directory dir
.
To use as a type in place of dir
, we recommend creating an empty
data type representing the specific directory, e.g. data ProjectRootDir
.
Means that path points to a file file
.
To use as a type in place of file
, we recommend creating an empty
data type representing the specific file, e.g. data ProjectManifestFile
.
Describes Path
standard as posix (e.g. /path/to/foobar
).
This makes Path
behave in system-independent fashion: code behaves the same
regardless of the system it is running on.
You will normally want to use it when dealing with paths from some external source,
or with paths that have explicitely fixed standard.
For example, if you are running your Haskell program on Windows and parsing logs which
were obtained from the Linux server, or maybe you are parsing Javascript import statements,
you will want to use Posix
.
Describes Path
standard to be determined by the system/OS.
If the system is Windows, it will resolve to Windows
internally, and if not,
it will resolve to Posix
.
However, keep in mind that even if running on Windows, Path Windows b t
and Path System b t
are still considered to be different types,
even though Path System b t
internally uses Windows standard.
You will normally want to use System
if you are dealing with the paths on the disk of the host OS
(where your code is running), for example if user is providing you with the path to the file on the disk
that you will be doing something with.
Keep in mind that System
causes the behaviour of Path
to be system/platform-dependant.
type Path' = Path System Source #
System
is the most commonly used standard, so we provide you with a type alias for it.
When you don't want your path to be relative to anything specific,
it is convenient to use unit ()
.
When you don't want your directory path to be named,
it is convenient to use unit ()
.
When you don't want your file path to be named,
it is convenient to use unit ()
.
parseRelFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d) t) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d) t) Source #
extractRelPathPrefix :: [Char] -> FilePath -> (RelPathPrefix, FilePath) Source #
Extracts a multiple "../" from start of the file path. If path is completely ......, also handles the last one. NOTE: We don't normalize path in any way.
relPathPrefix :: Path s (Rel r) t -> RelPathPrefix Source #
impossible :: a Source #