-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Strongly typed paths in Haskell. -- -- Replacement for a FilePath that enables you to handle filepaths in -- your code in a type-safe manner. You can specify at type level if they -- are relative, absolute, file, directory, posix, windows, and even to -- which file or directory they point to or are relative to. @package strong-path @version 1.1.3.0 module StrongPath.Internal -- | Strongly typed file path. Central type of the StrongPath. -- --
-- Path System (Dir HomeDir) (File FooFile) -- Path System Abs (Dir HomeDir) -- Path Posix (Rel ProjectRoot) (File ()) --data Path s b t RelDir :: Path Rel Dir -> RelPathPrefix -> Path s b t RelFile :: Path Rel File -> RelPathPrefix -> Path s b t AbsDir :: Path Abs Dir -> Path s b t AbsFile :: Path Abs File -> Path s b t RelDirW :: Path Rel Dir -> RelPathPrefix -> Path s b t RelFileW :: Path Rel File -> RelPathPrefix -> Path s b t AbsDirW :: Path Abs Dir -> Path s b t AbsFileW :: Path Abs File -> Path s b t RelDirP :: Path Rel Dir -> RelPathPrefix -> Path s b t RelFileP :: Path Rel File -> RelPathPrefix -> Path s b t AbsDirP :: Path Abs Dir -> Path s b t AbsFileP :: Path Abs File -> Path s b t data RelPathPrefix -- | ../, Int saying how many times it repeats. ParentDir :: Int -> RelPathPrefix NoPrefix :: RelPathPrefix -- | Describes Path base as absolute. data Abs -- | Describes Path base as relative to the directory dir. data 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. data 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. data 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. data Posix -- | Describes Path standard as windows (e.g. -- C:\path\to\foobar). Check Posix for more details, -- everything is analogous. data Windows -- | 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. data System -- | System is the most commonly used standard, so we provide you -- with a type alias for it. type Path' = Path System -- | When you don't want your file path to be named, it is convenient to -- use unit (). type File' = File () -- | When you don't want your directory path to be named, it is convenient -- to use unit (). type Dir' = Dir () -- | When you don't want your path to be relative to anything specific, it -- is convenient to use unit (). 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 -- | 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. extractRelPathPrefix :: [Char] -> FilePath -> (RelPathPrefix, FilePath) instance Data.Data.Data StrongPath.Internal.RelPathPrefix instance Language.Haskell.TH.Syntax.Lift StrongPath.Internal.RelPathPrefix instance GHC.Classes.Eq StrongPath.Internal.RelPathPrefix instance GHC.Show.Show StrongPath.Internal.RelPathPrefix instance (Data.Data.Data s, Data.Data.Data b, Data.Data.Data t) => Data.Data.Data (StrongPath.Internal.Path s b t) instance Language.Haskell.TH.Syntax.Lift (StrongPath.Internal.Path s b t) instance GHC.Classes.Eq (StrongPath.Internal.Path s b t) instance GHC.Show.Show (StrongPath.Internal.Path s b t) instance Data.Data.Data StrongPath.Internal.Abs instance Language.Haskell.TH.Syntax.Lift StrongPath.Internal.Abs instance Data.Data.Data dir => Data.Data.Data (StrongPath.Internal.Rel dir) instance Language.Haskell.TH.Syntax.Lift (StrongPath.Internal.Rel dir) instance Data.Data.Data dir => Data.Data.Data (StrongPath.Internal.Dir dir) instance Language.Haskell.TH.Syntax.Lift (StrongPath.Internal.Dir dir) instance Data.Data.Data file => Data.Data.Data (StrongPath.Internal.File file) instance Language.Haskell.TH.Syntax.Lift (StrongPath.Internal.File file) instance Data.Data.Data StrongPath.Internal.Posix instance Language.Haskell.TH.Syntax.Lift StrongPath.Internal.Posix instance Data.Data.Data StrongPath.Internal.Windows instance Language.Haskell.TH.Syntax.Lift StrongPath.Internal.Windows instance Data.Data.Data StrongPath.Internal.System instance Language.Haskell.TH.Syntax.Lift StrongPath.Internal.System module StrongPath.Path fromPathRelDir :: Path Rel Dir -> Path System (Rel a) (Dir b) fromPathRelFile :: Path Rel File -> Path System (Rel a) (File f) fromPathAbsDir :: Path Abs Dir -> Path System Abs (Dir a) fromPathAbsFile :: Path Abs File -> Path System Abs (File f) fromPathRelDirW :: Path Rel Dir -> Path Windows (Rel a) (Dir b) fromPathRelFileW :: Path Rel File -> Path Windows (Rel a) (File f) fromPathAbsDirW :: Path Abs Dir -> Path Windows Abs (Dir a) fromPathAbsFileW :: Path Abs File -> Path Windows Abs (File f) fromPathRelDirP :: Path Rel Dir -> Path Posix (Rel a) (Dir b) fromPathRelFileP :: Path Rel File -> Path Posix (Rel a) (File f) fromPathAbsDirP :: Path Abs Dir -> Path Posix Abs (Dir a) fromPathAbsFileP :: Path Abs File -> Path Posix Abs (File f) toPathRelDir :: Path System (Rel a) (Dir b) -> Path Rel Dir toPathRelFile :: Path System (Rel a) (File f) -> Path Rel File toPathAbsDir :: Path System Abs (Dir a) -> Path Abs Dir toPathAbsFile :: Path System Abs (File f) -> Path Abs File toPathRelDirW :: Path Windows (Rel a) (Dir b) -> Path Rel Dir toPathRelFileW :: Path Windows (Rel a) (File f) -> Path Rel File toPathAbsDirW :: Path Windows Abs (Dir a) -> Path Abs Dir toPathAbsFileW :: Path Windows Abs (File f) -> Path Abs File toPathRelDirP :: Path Posix (Rel a) (Dir b) -> Path Rel Dir toPathRelFileP :: Path Posix (Rel a) (File f) -> Path Rel File toPathAbsDirP :: Path Posix Abs (Dir a) -> Path Abs Dir toPathAbsFileP :: Path Posix Abs (File f) -> Path Abs File module StrongPath.Instances instance Data.Hashable.Class.Hashable (StrongPath.Internal.Path s b t) module StrongPath -- | Strongly typed file path. Central type of the StrongPath. -- --
-- Path System (Dir HomeDir) (File FooFile) -- Path System Abs (Dir HomeDir) -- Path Posix (Rel ProjectRoot) (File ()) --data Path s b t -- | 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. data 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. data File file -- | Describes Path base as absolute. data Abs -- | Describes Path base as relative to the directory dir. data Rel dir -- | 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. data Posix -- | Describes Path standard as windows (e.g. -- C:\path\to\foobar). Check Posix for more details, -- everything is analogous. data Windows -- | 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. data System -- | System is the most commonly used standard, so we provide you -- with a type alias for it. type Path' = Path System -- | When you don't want your path to be relative to anything specific, it -- is convenient to use unit (). type Rel' = Rel () -- | When you don't want your directory path to be named, it is convenient -- to use unit (). type Dir' = Dir () -- | When you don't want your file path to be named, it is convenient to -- use unit (). type File' = File () parseRelDir :: MonadThrow m => FilePath -> m (Path System (Rel d1) (Dir d2)) parseRelFile :: MonadThrow m => FilePath -> m (Path System (Rel d) (File f)) parseAbsDir :: MonadThrow m => FilePath -> m (Path System Abs (Dir d)) parseAbsFile :: MonadThrow m => FilePath -> m (Path System Abs (File f)) parseRelDirW :: MonadThrow m => FilePath -> m (Path Windows (Rel d1) (Dir d2)) parseRelFileW :: MonadThrow m => FilePath -> m (Path Windows (Rel d) (File f)) parseAbsDirW :: MonadThrow m => FilePath -> m (Path Windows Abs (Dir d)) parseAbsFileW :: MonadThrow m => FilePath -> m (Path Windows Abs (File f)) parseRelDirP :: MonadThrow m => FilePath -> m (Path Posix (Rel d1) (Dir d2)) parseRelFileP :: MonadThrow m => FilePath -> m (Path Posix (Rel d) (File f)) parseAbsDirP :: MonadThrow m => FilePath -> m (Path Posix Abs (Dir d)) parseAbsFileP :: MonadThrow m => FilePath -> m (Path Posix Abs (File f)) toFilePath :: Path s b t -> FilePath fromRelDir :: Path System (Rel r) (Dir d) -> FilePath fromRelFile :: Path System (Rel r) (File f) -> FilePath fromAbsDir :: Path System Abs (Dir d) -> FilePath fromAbsFile :: Path System Abs (File f) -> FilePath fromRelDirP :: Path Posix (Rel r) (Dir d) -> FilePath fromRelFileP :: Path Posix (Rel r) (File f) -> FilePath fromAbsDirP :: Path Posix Abs (Dir d) -> FilePath fromAbsFileP :: Path Posix Abs (File f) -> FilePath fromRelDirW :: Path Windows (Rel r) (Dir d) -> FilePath fromRelFileW :: Path Windows (Rel r) (File f) -> FilePath fromAbsDirW :: Path Windows Abs (Dir d) -> FilePath fromAbsFileW :: Path Windows Abs (File f) -> FilePath -- | Concatenates two paths, same as FilePath.</>, but -- only if the second path is relative to the directory that first path -- leads to, and if both paths use the same path standard. -- -- How "../"s are resolved (examples are pseudocode): -- --
-- "a/b" </> "../c" == "a/c" ---- --
-- "/a/b" </> "../../../../../c" == "/c" ---- --
-- "a/b" </> "../../../../../c" == "../../../c" --(>) :: Path s b (Dir d) -> Path s (Rel d) t -> Path s b t -- | Gets parent dir of the path. -- -- Either removes last entry in the path or if there are no entries and -- just "../"s, adds one more "../". -- -- If path is absolute root and it has no parent, it will return -- unchanged path. -- -- Examples (pseudocode): -- --
-- parent "a/b/c" == "a/b" -- parent "/a" == "/" -- parent "/" == "/" -- parent "../a/b" == "../a" -- parent ".." == "../.." -- parent (parent "../a") == "../.." --parent :: Path s b t -> Path s b (Dir d) -- | Returns the most right member of the path once split by separators. If -- path is pointing to file, basename will be name of the file. If path -- is pointing to a directory, basename will be name of the directory. -- Check examples below to see how are special paths like .., -- ., / and similar resolved. -- -- Examples (pseudocode): > basename "ab/c" == "c" > -- basename "file.txt" == "file.txt" > basename "../file.txt" == -- "file.txt" > basename "../.." == ".." > basename ".." == ".." -- > basename "." == "." > basename "/" == "." basename :: Path s b t -> Path s (Rel d) t -- | Enables you to redefine which dir is the path relative to. castRel :: Path s (Rel d1) a -> Path s (Rel d2) a -- | Enables you to rename the dir. castDir :: Path s a (Dir d1) -> Path s a (Dir d2) -- | Enables you to rename the file. castFile :: Path s a (File f1) -> Path s a (File f2) -- | Converts relative dir path to posix by replacing current path -- separators with posix path separators. If path is already posix, it -- will not change. -- -- Works well for "normal" relative paths like "a\b\c" (Win) or -- "a/b/c" (Posix). If path is weird but still considered -- relative, like just "C:" on Win, results can be unexpected, -- most likely resulting with error thrown. relDirToPosix :: MonadThrow m => Path s (Rel d1) (Dir d2) -> m (Path Posix (Rel d1) (Dir d2)) -- | Converts relative file path to posix, if it is not already posix. -- Check relDirToPosix for more details, they behave the same. relFileToPosix :: MonadThrow m => Path s (Rel d1) (File f) -> m (Path Posix (Rel d1) (File f)) absdir :: QuasiQuoter absdirP :: QuasiQuoter absdirW :: QuasiQuoter absfile :: QuasiQuoter absfileP :: QuasiQuoter absfileW :: QuasiQuoter reldir :: QuasiQuoter reldirP :: QuasiQuoter reldirW :: QuasiQuoter relfile :: QuasiQuoter relfileP :: QuasiQuoter relfileW :: QuasiQuoter