-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Path -- @package path @version 0.0.1 -- | Internal types and functions. module Path.Internal -- | Path of some base and type. -- -- Internally is a string. The string can be of two formats only: -- --
    --
  1. File format: file.txt, foo/bar.txt, -- /foo/bar.txt
  2. --
  3. Directory format: foo/, /foo/bar/
  4. --
-- -- All directories end in a trailing separator. There are no duplicate -- path separators //, no .., no ./, no -- ~/, etc. newtype Path b t Path :: FilePath -> Path b t instance Typeable Path instance Generic (Path b t) instance Datatype D1Path instance Constructor C1_0Path instance Show (Path b t) instance Ord (Path b t) instance Eq (Path b t) -- | A normalizing well-typed path type. module Path -- | Path of some base and type. -- -- Internally is a string. The string can be of two formats only: -- --
    --
  1. File format: file.txt, foo/bar.txt, -- /foo/bar.txt
  2. --
  3. Directory format: foo/, /foo/bar/
  4. --
-- -- All directories end in a trailing separator. There are no duplicate -- path separators //, no .., no ./, no -- ~/, etc. data Path b t -- | An absolute path. data Abs -- | A relative path; one without a root. data Rel -- | A file path. data File -- | A directory path. data Dir -- | Get a location for an absolute directory. Produces a normalized path -- which always ends in a path separator. -- -- Throws: PathParseException parseAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir) -- | Get a location for a relative directory. Produces a normalized path -- which always ends in a path separator. -- -- Throws: PathParseException parseRelDir :: MonadThrow m => FilePath -> m (Path Rel Dir) -- | Get a location for an absolute file. -- -- Throws: PathParseException parseAbsFile :: MonadThrow m => FilePath -> m (Path Abs File) -- | Get a location for a relative file. -- -- Throws: PathParseException parseRelFile :: MonadThrow m => FilePath -> m (Path Rel File) -- | Exception when parsing a location. data PathParseException -- | Make a 'Path Abs Dir'. -- -- Remember: due to the nature of absolute paths this (e.g. -- /home/foo) may compile on your platform, but it may not -- compile on another platform (Windows). mkAbsDir :: FilePath -> Q Exp -- | Make a 'Path Rel Dir'. mkRelDir :: FilePath -> Q Exp -- | Make a 'Path Abs File'. -- -- Remember: due to the nature of absolute paths this (e.g. -- /home/foo) may compile on your platform, but it may not -- compile on another platform (Windows). mkAbsFile :: FilePath -> Q Exp -- | Make a 'Path Rel File'. mkRelFile :: FilePath -> Q Exp -- | 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 …)
--   
() :: Path b Dir -> Path Rel t -> Path b t -- | Strip directory from path, making it relative to that directory. -- Returns Nothing if directory is not a parent of the path. -- -- The following properties hold: -- --
--   stripDir parent (parent </> child) = child
--   
-- -- Cases which are proven not possible: -- --
--   stripDir (a :: Path Abs …) (b :: Path Rel …)
--   
-- --
--   stripDir (a :: Path Rel) (b :: Path Abs …)
--   
-- -- In other words the bases must match. stripDir :: Path b Dir -> Path b t -> Maybe (Path Rel t) -- | Is p a parent of the given location? Implemented in terms of -- stripDir. The bases must match. isParentOf :: Path b Dir -> Path b t -> Bool -- | Take the absolute parent directory from the absolute path. -- -- The following properties hold: -- --
--   parentAbs (parent </> child) == parent
--   
-- -- On the root, getting the parent is idempotent: -- --
--   parentAbs (parentAbs "/") = "/"
--   
parentAbs :: Path Abs t -> Path Abs t -- | Extract the relative filename from a given location. -- -- The following properties hold: -- --
--   filename (parent </> filename a) == a
--   
filename :: Path b File -> Path Rel File -- | Convert to a FilePath type. toFilePath :: Path b t -> FilePath instance Typeable Abs instance Typeable Rel instance Typeable File instance Typeable Dir instance Typeable PathParseException instance Show PathParseException instance Exception PathParseException