License | MIT |
---|---|
Maintainer | dan.firth@homotopic.tech |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Polysemy versions of functions in the path library.
Synopsis
- data Path b t
- data Rel
- data Abs
- data File
- data Dir
- data SomeBase t
- data PathException
- absdir :: QuasiQuoter
- reldir :: QuasiQuoter
- absfile :: QuasiQuoter
- relfile :: QuasiQuoter
- (</>) :: Path b Dir -> Path Rel t -> Path b t
- stripProperPrefix :: Members '[Error PathException] r => Path b Dir -> Path b t -> Sem r (Path Rel t)
- isProperPrefixOf :: Path b Dir -> Path b t -> Bool
- parent :: Path b t -> Path b Dir
- filename :: Path b File -> Path Rel File
- dirname :: Path b Dir -> Path Rel Dir
- addExtension :: Members '[Error PathException] r => String -> Path b File -> Sem r (Path b File)
- splitExtension :: Members '[Error PathException] r => Path b File -> Sem r (Path b File, String)
- fileExtension :: Members '[Error PathException] r => Path b File -> Sem r String
- replaceExtension :: Members '[Error PathException] r => String -> Path b File -> Sem r (Path b File)
- parseRelFile :: Members '[Error PathException] r => FilePath -> Sem r (Path Rel File)
- parseAbsFile :: Members '[Error PathException] r => FilePath -> Sem r (Path Abs File)
- parseRelDir :: Members '[Error PathException] r => FilePath -> Sem r (Path Rel Dir)
- parseAbsDir :: Members '[Error PathException] r => FilePath -> Sem r (Path Abs Dir)
- parseSomeDir :: Members '[Error PathException] r => FilePath -> Sem r (SomeBase Dir)
- parseSomeFile :: Members '[Error PathException] r => FilePath -> Sem r (SomeBase File)
- toFilePath :: Path b t -> FilePath
- fromAbsDir :: Path Abs Dir -> FilePath
- fromRelDir :: Path Rel Dir -> FilePath
- fromAbsFile :: Path Abs File -> FilePath
- fromRelFile :: Path Rel File -> FilePath
- fromSomeDir :: SomeBase Dir -> FilePath
- fromSomeFile :: SomeBase File -> FilePath
- mkAbsDir :: FilePath -> Q Exp
- mkRelDir :: FilePath -> Q Exp
- mkAbsFile :: FilePath -> Q Exp
- mkRelFile :: FilePath -> Q Exp
Documentation
Path of some base and type.
The type variables are:
b
— base, the base location of the path; absolute or relative.t
— type, whether file or directory.
Internally is a string. The string can be of two formats only:
- File format:
file.txt
,foo/bar.txt
,/foo/bar.txt
- Directory format:
foo/
,/foo/bar/
All directories end in a trailing separator. There are no duplicate
path separators //
, no ..
, no ./
, no ~/
, etc.
Instances
(Typeable b, Typeable t) => Lift (Path b t :: Type) | |
Eq (Path b t) | String equality. The following property holds: show x == show y ≡ x == y |
(Data b, Data t) => Data (Path b t) | |
Defined in Path.Internal.Posix gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Path b t -> c (Path b t) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Path b t) # toConstr :: Path b t -> Constr # dataTypeOf :: Path b t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Path b t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Path b t)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Path b t -> Path b t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Path b t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Path b t -> r # gmapQ :: (forall d. Data d => d -> u) -> Path b t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Path b t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Path b t -> m (Path b t) # | |
Ord (Path b t) | String ordering. The following property holds: show x `compare` show y ≡ x `compare` y |
Defined in Path.Internal.Posix | |
Show (Path b t) | Same as 'show . Path.toFilePath'. The following property holds: x == y ≡ show x == show y |
Generic (Path b t) | |
Hashable (Path b t) | |
Defined in Path.Internal.Posix | |
ToJSON (Path b t) | |
Defined in Path.Internal.Posix | |
ToJSONKey (Path b t) | |
Defined in Path.Internal.Posix toJSONKey :: ToJSONKeyFunction (Path b t) # toJSONKeyList :: ToJSONKeyFunction [Path b t] # | |
FromJSON (Path Abs File) | |
FromJSON (Path Abs Dir) | |
FromJSON (Path Rel File) | |
FromJSON (Path Rel Dir) | |
FromJSONKey (Path Abs File) | |
Defined in Path.Posix | |
FromJSONKey (Path Abs Dir) | |
Defined in Path.Posix | |
FromJSONKey (Path Rel File) | |
Defined in Path.Posix | |
FromJSONKey (Path Rel Dir) | |
Defined in Path.Posix | |
NFData (Path b t) | |
Defined in Path.Internal.Posix | |
type Rep (Path b t) | |
Defined in Path.Internal.Posix |
A relative path; one without a root. Note that a ..
path component to
represent the parent directory is not allowed by this library.
Instances
FromJSON (Path Rel File) | |
FromJSON (Path Rel Dir) | |
FromJSONKey (Path Rel File) | |
Defined in Path.Posix | |
FromJSONKey (Path Rel Dir) | |
Defined in Path.Posix |
An absolute path.
Instances
FromJSON (Path Abs File) | |
FromJSON (Path Abs Dir) | |
FromJSONKey (Path Abs File) | |
Defined in Path.Posix | |
FromJSONKey (Path Abs Dir) | |
Defined in Path.Posix |
A file path.
A directory path.
Path of some type. t
represents the type, whether file or
directory. Pattern match to find whether the path is absolute or
relative.
Instances
Eq (SomeBase t) | |
Ord (SomeBase t) | |
Show (SomeBase t) | |
Generic (SomeBase t) | |
Hashable (SomeBase t) | |
Defined in Path.Posix | |
ToJSON (SomeBase t) | |
Defined in Path.Posix | |
FromJSON (SomeBase File) | |
FromJSON (SomeBase Dir) | |
NFData (SomeBase t) | |
Defined in Path.Posix | |
type Rep (SomeBase t) | |
Defined in Path.Posix type Rep (SomeBase t) = D1 ('MetaData "SomeBase" "Path.Posix" "path-0.9.0-1XaDMm6hRGZI4vY8hKM6Gz" 'False) (C1 ('MetaCons "Abs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Path Abs t))) :+: C1 ('MetaCons "Rel" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Path Rel t)))) |
data PathException #
Exceptions that can occur during path operations.
Since: path-0.6.0
Instances
Eq PathException | |
Defined in Path.Posix (==) :: PathException -> PathException -> Bool # (/=) :: PathException -> PathException -> Bool # | |
Show PathException | |
Defined in Path.Posix showsPrec :: Int -> PathException -> ShowS # show :: PathException -> String # showList :: [PathException] -> ShowS # | |
Exception PathException | |
Defined in Path.Posix |
absdir :: QuasiQuoter #
reldir :: QuasiQuoter #
absfile :: QuasiQuoter #
relfile :: QuasiQuoter #
(</>) :: Path b Dir -> Path Rel t -> Path b t infixr 5 #
Append two paths.
The following cases are valid and the equalities hold:
$(mkAbsDir x) </> $(mkRelDir y) = $(mkAbsDir (x ++ "/" ++ y))
$(mkAbsDir x) </> $(mkRelFile y) = $(mkAbsFile (x ++ "/" ++ y))
$(mkRelDir x) </> $(mkRelDir y) = $(mkRelDir (x ++ "/" ++ y))
$(mkRelDir x) </> $(mkRelFile y) = $(mkRelFile (x ++ "/" ++ y))
The following are proven not possible to express:
$(mkAbsFile …) </> x
$(mkRelFile …) </> x
x </> $(mkAbsFile …)
x </> $(mkAbsDir …)
stripProperPrefix :: Members '[Error PathException] r => Path b Dir -> Path b t -> Sem r (Path Rel t) Source #
Polysemy version of stripProperPrefix
.
Since: 0.1.0.0
isProperPrefixOf :: Path b Dir -> Path b t -> Bool #
Determines if the path in the first parameter is a proper prefix of the path in the second parameter.
The following properties hold:
not (x `isProperPrefixOf` x)
x `isProperPrefixOf` (x </> y)
Since: path-0.6.0
parent :: Path b t -> Path b Dir #
Take the parent path component from a path.
The following properties hold:
parent (x </> y) == x parent "/x" == "/" parent "x" == "."
On the root (absolute or relative), getting the parent is idempotent:
parent "/" = "/" parent "." = "."
filename :: Path b File -> Path Rel File #
Extract the file part of a path.
The following properties hold:
filename (p </> a) == filename a
dirname :: Path b Dir -> Path Rel Dir #
Extract the last directory name of a path.
The following properties hold:
dirname $(mkRelDir ".") == $(mkRelDir ".")
dirname (p </> a) == dirname a
addExtension :: Members '[Error PathException] r => String -> Path b File -> Sem r (Path b File) Source #
Polysemy version of addExtension
.
Since: 0.2.0.0
splitExtension :: Members '[Error PathException] r => Path b File -> Sem r (Path b File, String) Source #
Polysemy version of splitExtension
.
Since: 0.2.0.0
fileExtension :: Members '[Error PathException] r => Path b File -> Sem r String Source #
Polysemy version of fileExtension
.
Since: 0.2.0.0
replaceExtension :: Members '[Error PathException] r => String -> Path b File -> Sem r (Path b File) Source #
Polysemy version of replaceExtension
.
Since: 0.2.0.0
parseRelFile :: Members '[Error PathException] r => FilePath -> Sem r (Path Rel File) Source #
Polysemy version of parseRelFile
.
Since: 0.1.0.0
parseAbsFile :: Members '[Error PathException] r => FilePath -> Sem r (Path Abs File) Source #
Polysemy version of parseAbsFile
.
Since: 0.1.0.0
parseRelDir :: Members '[Error PathException] r => FilePath -> Sem r (Path Rel Dir) Source #
Polysemy version of parseRelDir
.
Since: 0.1.0.0
parseAbsDir :: Members '[Error PathException] r => FilePath -> Sem r (Path Abs Dir) Source #
Polysemy version of parseAbsDir
.
Since: 0.1.0.0
parseSomeDir :: Members '[Error PathException] r => FilePath -> Sem r (SomeBase Dir) Source #
Polysemy version of parseSomeDir
.
Since: 0.2.0.0
parseSomeFile :: Members '[Error PathException] r => FilePath -> Sem r (SomeBase File) Source #
Polysemy version of parseSomeFile
.
Since: 0.2.0.0
toFilePath :: Path b t -> FilePath #
Convert to a FilePath
type.
All directories have a trailing slash, so if you want no trailing
slash, you can use dropTrailingPathSeparator
from
the filepath package.