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 File' = File ()
- type Dir' = Dir ()
- type Rel' = Rel ()
- parseRelFileFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d) (File f)) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d) (File f))
- parseRelDirFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d1) (Dir d2)) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d1) (Dir d2))
- impossible :: a
- prefixNumParentDirs :: RelPathPrefix -> Int
- relPathNumParentDirs :: Path s (Rel r) t -> Int
- relPathPrefix :: Path s (Rel r) t -> RelPathPrefix
- extractRelPathPrefix :: [Char] -> FilePath -> (RelPathPrefix, FilePath)
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) |
Instances
Lift (Path s b t :: Type) Source # | |
Eq (Path s b t) Source # | |
(Data s, Data b, Data t) => Data (Path s b t) Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Path s b t -> c (Path s b t) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Path s b t) # toConstr :: Path s b t -> Constr # dataTypeOf :: Path s b t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Path s b t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Path s b t)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Path s b t -> Path s b t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Path s b t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Path s b t -> r # gmapQ :: (forall d. Data d => d -> u) -> Path s b t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Path s b t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Path s b t -> m (Path s b t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Path s b t -> m (Path s b t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Path s b t -> m (Path s b t) # | |
Show (Path s b t) Source # | |
data RelPathPrefix Source #
Instances
Describes Path
base as absolute.
Instances
Data Abs Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Abs -> c Abs # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Abs # dataTypeOf :: Abs -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Abs) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Abs) # gmapT :: (forall b. Data b => b -> b) -> Abs -> Abs # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Abs -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Abs -> r # gmapQ :: (forall d. Data d => d -> u) -> Abs -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Abs -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Abs -> m Abs # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Abs -> m Abs # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Abs -> m Abs # | |
Lift Abs Source # | |
Describes Path
base as relative to the directory dir
.
Instances
Lift (Rel dir :: Type) Source # | |
Data dir => Data (Rel dir) Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Rel dir -> c (Rel dir) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Rel dir) # toConstr :: Rel dir -> Constr # dataTypeOf :: Rel dir -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Rel dir)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Rel dir)) # gmapT :: (forall b. Data b => b -> b) -> Rel dir -> Rel dir # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Rel dir -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Rel dir -> r # gmapQ :: (forall d. Data d => d -> u) -> Rel dir -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Rel dir -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Rel dir -> m (Rel dir) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Rel dir -> m (Rel dir) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Rel dir -> m (Rel 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
.
Instances
Lift (Dir dir :: Type) Source # | |
Data dir => Data (Dir dir) Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dir dir -> c (Dir dir) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dir dir) # toConstr :: Dir dir -> Constr # dataTypeOf :: Dir dir -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dir dir)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Dir dir)) # gmapT :: (forall b. Data b => b -> b) -> Dir dir -> Dir dir # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dir dir -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dir dir -> r # gmapQ :: (forall d. Data d => d -> u) -> Dir dir -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dir dir -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dir dir -> m (Dir dir) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dir dir -> m (Dir dir) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dir dir -> m (Dir dir) # |
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
.
Instances
Lift (File file :: Type) Source # | |
Data file => Data (File file) Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> File file -> c (File file) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (File file) # toConstr :: File file -> Constr # dataTypeOf :: File file -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (File file)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (File file)) # gmapT :: (forall b. Data b => b -> b) -> File file -> File file # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> File file -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> File file -> r # gmapQ :: (forall d. Data d => d -> u) -> File file -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> File file -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> File file -> m (File file) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> File file -> m (File file) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> File file -> m (File file) # |
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
.
Instances
Data Posix Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Posix -> c Posix # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Posix # dataTypeOf :: Posix -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Posix) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Posix) # gmapT :: (forall b. Data b => b -> b) -> Posix -> Posix # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Posix -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Posix -> r # gmapQ :: (forall d. Data d => d -> u) -> Posix -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Posix -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Posix -> m Posix # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Posix -> m Posix # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Posix -> m Posix # | |
Lift Posix Source # | |
Describes Path
standard as windows (e.g. C:\path\to\foobar
).
Check Posix
for more details, everything is analogous.
Instances
Data Windows Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Windows -> c Windows # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Windows # toConstr :: Windows -> Constr # dataTypeOf :: Windows -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Windows) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Windows) # gmapT :: (forall b. Data b => b -> b) -> Windows -> Windows # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Windows -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Windows -> r # gmapQ :: (forall d. Data d => d -> u) -> Windows -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Windows -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Windows -> m Windows # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Windows -> m Windows # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Windows -> m Windows # | |
Lift Windows Source # | |
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.
Instances
Data System Source # | |
Defined in StrongPath.Internal gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> System -> c System # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c System # toConstr :: System -> Constr # dataTypeOf :: System -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c System) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c System) # gmapT :: (forall b. Data b => b -> b) -> System -> System # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> System -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> System -> r # gmapQ :: (forall d. Data d => d -> u) -> System -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> System -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> System -> m System # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> System -> m System # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> System -> m System # | |
Lift System Source # | |
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 file path to be named,
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 path to be relative to anything specific,
it is convenient to use unit ()
.
parseRelFileFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d) (File f)) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d) (File f)) Source #
parseRelDirFP :: MonadThrow m => (p -> RelPathPrefix -> Path s (Rel d1) (Dir d2)) -> [Char] -> (FilePath -> m p) -> FilePath -> m (Path s (Rel d1) (Dir d2)) Source #
impossible :: a Source #
relPathPrefix :: Path s (Rel r) t -> RelPathPrefix 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.