-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Support for well-typed paths
--   
--   Support for well-typed paths.
@package path
@version 0.9.6

-- | Internal types and functions.
module OsPath.Internal.Posix

-- | 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 it is a PosixPath, which 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.
newtype Path b t
Path :: PosixPath -> Path b t

-- | Convert to a PosixPath type.
--   
--   All directories have a trailing slash, so if you want no trailing
--   slash, you can use dropTrailingPathSeparator from the filepath
--   package.
toOsPath :: Path b t -> PosixPath

-- | Is the PosixPath a valid absolute dir?
isValidAbsDir :: PosixPath -> Bool

-- | Is the PosixPath a valid absolute file?
isValidAbsFile :: PosixPath -> Bool

-- | Is the PosixPath a valid relative dir?
isValidRelDir :: PosixPath -> Bool

-- | Is the PosixPath a valid relative file?
isValidRelFile :: PosixPath -> Bool

-- | Helper function: check if the filepath has any parent directories in
--   it. This handles the logic of checking for different path separators
--   on Windows.
hasParentDir :: PosixPath -> Bool

-- | Normalizes seps only at the beginning of a path.
normalizeLeadingSeps :: PosixPath -> PosixPath

-- | Normalizes seps only at the end of a path.
normalizeTrailingSeps :: PosixPath -> PosixPath

-- | Replaces consecutive path seps with single sep and replaces alt sep
--   with standard sep.
normalizeAllSeps :: PosixPath -> PosixPath

-- | Normalizes the drive of a PosixPath.
normalizeDrive :: PosixPath -> PosixPath

-- | Normalizes directory path with platform-specific rules.
normalizeDir :: PosixPath -> PosixPath

-- | Applies platform-specific sep normalization following
--   OsPath.normalise.
normalizeFile :: PosixPath -> PosixPath
extSep :: PosixString
pathSep :: PosixString

-- | Normalized file path representation for the relative path root
relRoot :: PosixPath
isWindows :: Bool
instance (GHC.Internal.Data.Data.Data b, GHC.Internal.Data.Data.Data t) => GHC.Internal.Data.Data.Data (OsPath.Internal.Posix.Path b t)
instance GHC.Classes.Eq (OsPath.Internal.Posix.Path b t)
instance GHC.Internal.Generics.Generic (OsPath.Internal.Posix.Path b t)
instance Data.Hashable.Class.Hashable (OsPath.Internal.Posix.Path b t)
instance (GHC.Internal.Data.Typeable.Internal.Typeable b, GHC.Internal.Data.Typeable.Internal.Typeable t) => Language.Haskell.TH.Syntax.Lift (OsPath.Internal.Posix.Path b t)
instance Control.DeepSeq.NFData (OsPath.Internal.Posix.Path b t)
instance GHC.Classes.Ord (OsPath.Internal.Posix.Path b t)
instance GHC.Internal.Show.Show (OsPath.Internal.Posix.Path b t)

module OsPath.Internal

-- | Internal types and functions.
module OsPath.Internal.Windows

-- | 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 it is a WindowsPath, which 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.
newtype Path b t
Path :: WindowsPath -> Path b t

-- | Convert to a WindowsPath type.
--   
--   All directories have a trailing slash, so if you want no trailing
--   slash, you can use dropTrailingPathSeparator from the filepath
--   package.
toOsPath :: Path b t -> WindowsPath

-- | Is the WindowsPath a valid absolute dir?
isValidAbsDir :: WindowsPath -> Bool

-- | Is the WindowsPath a valid absolute file?
isValidAbsFile :: WindowsPath -> Bool

-- | Is the WindowsPath a valid relative dir?
isValidRelDir :: WindowsPath -> Bool

-- | Is the WindowsPath a valid relative file?
isValidRelFile :: WindowsPath -> Bool

-- | Helper function: check if the filepath has any parent directories in
--   it. This handles the logic of checking for different path separators
--   on Windows.
hasParentDir :: WindowsPath -> Bool

-- | Normalizes seps only at the beginning of a path.
normalizeLeadingSeps :: WindowsPath -> WindowsPath

-- | Normalizes seps only at the end of a path.
normalizeTrailingSeps :: WindowsPath -> WindowsPath

-- | Replaces consecutive path seps with single sep and replaces alt sep
--   with standard sep.
normalizeAllSeps :: WindowsPath -> WindowsPath

-- | Normalizes seps in whole path, but if there are 2+ seps at the
--   beginning, they are normalized to exactly 2 to preserve UNC and
--   Unicode prefixed paths.
normalizeWindowsSeps :: WindowsPath -> WindowsPath

-- | Normalizes the drive of a WindowsPath.
normalizeDrive :: WindowsPath -> WindowsPath

-- | Normalizes directory path with platform-specific rules.
normalizeDir :: WindowsPath -> WindowsPath

-- | Applies platform-specific sep normalization following
--   OsPath.normalise.
normalizeFile :: WindowsPath -> WindowsPath
extSep :: WindowsString
pathSep :: WindowsString

-- | Normalized file path representation for the relative path root
relRoot :: WindowsPath
isWindows :: Bool
instance (GHC.Internal.Data.Data.Data b, GHC.Internal.Data.Data.Data t) => GHC.Internal.Data.Data.Data (OsPath.Internal.Windows.Path b t)
instance GHC.Classes.Eq (OsPath.Internal.Windows.Path b t)
instance GHC.Internal.Generics.Generic (OsPath.Internal.Windows.Path b t)
instance Data.Hashable.Class.Hashable (OsPath.Internal.Windows.Path b t)
instance (GHC.Internal.Data.Typeable.Internal.Typeable b, GHC.Internal.Data.Typeable.Internal.Typeable t) => Language.Haskell.TH.Syntax.Lift (OsPath.Internal.Windows.Path b t)
instance Control.DeepSeq.NFData (OsPath.Internal.Windows.Path b t)
instance GHC.Classes.Ord (OsPath.Internal.Windows.Path b t)
instance GHC.Internal.Show.Show (OsPath.Internal.Windows.Path b t)

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Note: This module is for working with Posix style paths.
--   Importing Path is usually better.
--   
--   A path is represented by a number of path components separated by a
--   path separator which is a / on POSIX systems and can be a
--   / or \ on Windows. The root of the tree is
--   represented by a / on POSIX and a drive letter followed by a
--   / or \ on Windows (e.g. C:\). Paths can be
--   absolute or relative. An absolute path always starts from the root of
--   the tree (e.g. /x/y) whereas a relative path never starts
--   with the root (e.g. x/y). Just like we represent the notion
--   of an absolute root by "/", the same way we represent the
--   notion of a relative root by ".". The relative root denotes
--   the directory which contains the first component of a relative path.
module OsPath.Posix

-- | 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 it is a PosixPath, which 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.
data Path b t

-- | An absolute path.
data Abs

-- | A relative path; one without a root. Note that a .. path
--   component to represent the parent directory is not allowed by this
--   library.
data Rel

-- | A file path.
data File

-- | A directory path.
data Dir

-- | Path of some type. t represents the type, whether file or
--   directory. Pattern match to find whether the path is absolute or
--   relative.
data SomeBase t
Abs :: Path Abs t -> SomeBase t
Rel :: Path Rel t -> SomeBase t

-- | Exceptions that can occur during path operations.
data PathException
InvalidAbsDir :: PosixPath -> PathException
InvalidRelDir :: PosixPath -> PathException
InvalidAbsFile :: PosixPath -> PathException
InvalidRelFile :: PosixPath -> PathException
InvalidFile :: PosixPath -> PathException
InvalidDir :: PosixPath -> PathException
NotAProperPrefix :: PosixPath -> PosixPath -> PathException
HasNoExtension :: PosixPath -> PathException
InvalidExtension :: PosixString -> PathException

-- | Construct a Path Abs Dir using QuasiQuotes.
--   
--   
--   [absdir|/|]
--   
--   [absdir|/home/chris|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris|] may compile on your platform, but it
--   may not compile on another platform (Windows).
absdir :: QuasiQuoter

-- | Construct a Path Rel Dir using QuasiQuotes.
--   
--   
--   [absdir|/home|]</>[reldir|chris|]
--   
reldir :: QuasiQuoter

-- | Construct a Path Abs File using QuasiQuotes.
--   
--   
--   [absfile|/home/chris/foo.txt|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris/foo.txt|] may compile on your platform,
--   but it may not compile on another platform (Windows).
absfile :: QuasiQuoter

-- | Construct a Path Rel File using QuasiQuotes.
--   
--   
--   [absdir|/home/chris|]</>[relfile|foo.txt|]
--   
relfile :: QuasiQuoter

-- | Append two paths.
--   
--   The following cases are valid and the equalities hold:
--   
--   
--   $(mkAbsDir x) </> $(mkRelDir y) = $(mkAbsDir (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkAbsDir x) </> $(mkRelFile y) = $(mkAbsFile (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkRelDir x) </> $(mkRelDir y) = $(mkRelDir (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkRelDir x) </> $(mkRelFile y) = $(mkRelFile (x <> [pstr|/|] <> 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
infixr 5 </>

-- | If the directory in the first argument is a proper prefix of the path
--   in the second argument strip it from the second argument, generating a
--   path relative to the directory. Throws NotAProperPrefix if the
--   directory is not a proper prefix of the path.
--   
--   The following properties hold:
--   
--   
--   stripProperPrefix x (x </> y) = y
--   
--   
--   Cases which are proven not possible:
--   
--   
--   stripProperPrefix (a :: Path Abs …) (b :: Path Rel …)
--   
--   
--   
--   stripProperPrefix (a :: Path Rel …) (b :: Path Abs …)
--   
--   
--   In other words the bases must match.
stripProperPrefix :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | 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)
--   
isProperPrefixOf :: Path b Dir -> Path b t -> Bool

-- | Change from one directory prefix to another.
--   
--   Throw NotAProperPrefix if the first argument is not a proper
--   prefix of the path.
--   
--   
--   >>> replaceProperPrefix $(mkRelDir "foo") $(mkRelDir "bar") $(mkRelFile "foo/file.txt") == $(mkRelFile "bar/file.txt")
--   
replaceProperPrefix :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)

-- | Take the parent path component from a path.
--   
--   The following properties hold:
--   
--   
--   parent (x </> y) == x
--   parent [pstr|/x|] == [pstr|/|]
--   parent [pstr|x|] == [pstr|.|]
--   
--   
--   On the root (absolute or relative), getting the parent is idempotent:
--   
--   
--   parent [pstr|/|] = [pstr|/|]
--   parent [pstr|.|] = [pstr|.|]
--   
parent :: Path b t -> Path b Dir

-- | Extract the file part of a path.
--   
--   The following properties hold:
--   
--   
--   filename (p </> a) == filename a
--   
filename :: Path b File -> Path Rel File

-- | Extract the last directory name of a path.
--   
--   The following properties hold:
--   
--   
--   dirname $(mkRelDir ".") == $(mkRelDir ".")
--   
--   
--   
--   dirname (p </> a) == dirname a
--   
dirname :: Path b Dir -> Path Rel Dir

-- | Add extension to given file path.
--   
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo"    )
--   
--   >>> addExtension [pstr|.foo.|]  $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo."   )
--   
--   >>> addExtension [pstr|.foo..|] $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo.."  )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name.bar" ) == Just $(mkRelFile "name.bar.foo")
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile ".name"    ) == Just $(mkRelFile ".name.foo"   )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name."    ) == Just $(mkRelFile "name..foo"   )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "..."      ) == Just $(mkRelFile "....foo"     )
--   
--   
--   Throws an InvalidExtension exception if the extension is not
--   valid. A valid extension starts with a . followed by one or
--   more characters not including . followed by zero or more
--   . in trailing position. Moreover, an extension must be a
--   valid filename, notably it cannot include path separators.
--   Particularly, .foo.bar is an invalid extension, instead you
--   have to first set .foo and then .bar individually.
--   Some examples of invalid extensions are:
--   
--   
--   >>> addExtension [pstr|foo|]      $(mkRelFile "name")
--   
--   >>> addExtension [pstr|..foo|]    $(mkRelFile "name")
--   
--   >>> addExtension [pstr|.foo.bar|] $(mkRelFile "name")
--   
--   >>> addExtension [pstr|.foo/bar|] $(mkRelFile "name")
--   
addExtension :: MonadThrow m => PosixString -> Path b File -> m (Path b File)

-- | splitExtension is the inverse of addExtension. It splits
--   the given file path into a valid filename and a valid extension.
--   
--   
--   >>> splitExtension $(mkRelFile "name.foo"     ) == Just ($(mkRelFile "name"    ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "name.foo."    ) == Just ($(mkRelFile "name"    ), [pstr|.foo.|] )
--   
--   >>> splitExtension $(mkRelFile "name.foo.."   ) == Just ($(mkRelFile "name"    ), [pstr|.foo..|])
--   
--   >>> splitExtension $(mkRelFile "name.bar.foo" ) == Just ($(mkRelFile "name.bar"), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile ".name.foo"    ) == Just ($(mkRelFile ".name"   ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "name..foo"    ) == Just ($(mkRelFile "name."   ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "....foo"      ) == Just ($(mkRelFile "..."     ), [pstr|.foo|]  )
--   
--   
--   Throws HasNoExtension exception if the filename does not have
--   an extension or in other words it cannot be split into a valid
--   filename and a valid extension. The following cases throw an
--   exception, please note that "." and ".." are not valid filenames:
--   
--   
--   >>> splitExtension $(mkRelFile "name"   )
--   
--   >>> splitExtension $(mkRelFile "name."  )
--   
--   >>> splitExtension $(mkRelFile "name.." )
--   
--   >>> splitExtension $(mkRelFile ".name"  )
--   
--   >>> splitExtension $(mkRelFile "..name" )
--   
--   >>> splitExtension $(mkRelFile "...name")
--   
--   
--   splitExtension and addExtension are inverses of each
--   other, the following laws hold:
--   
--   
--   uncurry addExtension . swap >=> splitExtension == return
--   splitExtension >=> uncurry addExtension . swap == return
--   
splitExtension :: MonadThrow m => Path b File -> m (Path b File, PosixString)

-- | Get extension from given file path. Throws HasNoExtension
--   exception if the file does not have an extension. The following laws
--   hold:
--   
--   
--   flip addExtension file >=> fileExtension == return
--   fileExtension == (fmap snd) . splitExtension
--   
fileExtension :: MonadThrow m => Path b File -> m PosixString

-- | If the file has an extension replace it with the given extension
--   otherwise add the new extension to it. Throws an
--   InvalidExtension exception if the new extension is not a valid
--   extension (see fileExtension for validity rules).
--   
--   The following law holds:
--   
--   
--   (fileExtension >=> flip replaceExtension file) file == return file
--   
replaceExtension :: MonadThrow m => PosixString -> Path b File -> m (Path b File)

-- | Split an absolute path into a drive and, perhaps, a path. On POSIX,
--   / is a drive.
splitDrive :: Path Abs t -> (Path Abs Dir, Maybe (Path Rel t))

-- | Get the drive from an absolute path. On POSIX, / is a drive.
--   
--   
--   takeDrive x = fst (splitDrive x)
--   
takeDrive :: Path Abs t -> Path Abs Dir

-- | Drop the drive from an absolute path. May result in Nothing if
--   the path is just a drive.
--   
--   
--   dropDrive x = snd (splitDrive x)
--   
dropDrive :: Path Abs t -> Maybe (Path Rel t)

-- | Is an absolute directory path a drive?
isDrive :: Path Abs Dir -> Bool

-- | Helper to apply a function to the SomeBase object
--   
--   
--   >>> mapSomeBase parent (Abs [absfile|/foo/bar/cow.moo|]) == Abs [absdir|/foo/bar|]
--   
mapSomeBase :: (forall b. () => Path b t -> Path b t') -> SomeBase t -> SomeBase t'

-- | Helper to project the contents out of a SomeBase object.
--   
--   
--   >>> prjSomeBase toOsPath (Abs [absfile|/foo/bar/cow.moo|]) == [pstr|/foo/bar/cow.moo|]
--   
prjSomeBase :: (forall b. () => Path b t -> a) -> SomeBase t -> a

-- | Convert an absolute PosixPath to a normalized absolute dir
--   Path.
--   
--   Throws: InvalidAbsDir when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsDir :: MonadThrow m => PosixPath -> m (Path Abs Dir)

-- | Convert a relative PosixPath to a normalized relative dir
--   Path.
--   
--   Throws: InvalidRelDir when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
- is all path separators
--   
parseRelDir :: MonadThrow m => PosixPath -> m (Path Rel Dir)

-- | Convert an absolute PosixPath to a normalized absolute file
--   Path.
--   
--   Throws: InvalidAbsFile when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsFile :: MonadThrow m => PosixPath -> m (Path Abs File)

-- | Convert a relative PosixPath to a normalized relative file
--   Path.
--   
--   Throws: InvalidRelFile when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseRelFile :: MonadThrow m => PosixPath -> m (Path Rel File)

-- | Convert an absolute or relative PosixPath to a normalized
--   SomeBase representing a directory.
--   
--   Throws: InvalidDir when the supplied path:
--   
--   
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeDir :: MonadThrow m => PosixPath -> m (SomeBase Dir)

-- | Convert an absolute or relative PosixPath to a normalized
--   SomeBase representing a file.
--   
--   Throws: InvalidFile when the supplied path:
--   
--   
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeFile :: MonadThrow m => PosixPath -> m (SomeBase File)

-- | Convert to a PosixPath type.
--   
--   All directories have a trailing slash, so if you want no trailing
--   slash, you can use dropTrailingPathSeparator from the filepath
--   package.
toOsPath :: Path b t -> PosixPath

-- | Convert absolute path to directory to PosixPath type.
fromAbsDir :: Path Abs Dir -> PosixPath

-- | Convert relative path to directory to PosixPath type.
fromRelDir :: Path Rel Dir -> PosixPath

-- | Convert absolute path to file to PosixPath type.
fromAbsFile :: Path Abs File -> PosixPath

-- | Convert relative path to file to PosixPath type.
fromRelFile :: Path Rel File -> PosixPath

-- | Convert a valid path to a PosixPath.
fromSomeBase :: SomeBase t -> PosixPath

-- | Convert a valid directory to a PosixPath.
fromSomeDir :: SomeBase Dir -> PosixPath

-- | Convert a valid file to a PosixPath.
fromSomeFile :: SomeBase File -> PosixPath

-- | 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 :: PosixPath -> Q Exp

-- | Make a Path Rel Dir.
mkRelDir :: PosixPath -> 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 :: PosixPath -> Q Exp

-- | Make a Path Rel File.
mkRelFile :: PosixPath -> Q Exp

-- | Same as PathException.

-- | Deprecated: Please use PathException instead.
type PathParseException = PathException

-- | Same as stripProperPrefix.

-- | Deprecated: Please use stripProperPrefix instead.
stripDir :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | Same as isProperPrefixOf.

-- | Deprecated: Please use isProperPrefixOf instead.
isParentOf :: Path b Dir -> Path b t -> Bool

-- | Add extension to given file path. Throws if the resulting filename
--   does not parse.
--   
--   
--   >>> addFileExtension [pstr|txt|] $(mkRelFile "foo")
--   "foo.txt"
--   
--   >>> addFileExtension [pstr|symbols|] $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension [pstr|.symbols|] $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension [pstr|symbols|] $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension [pstr|.symbols|] $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension [pstr|evil/|] $(mkRelFile "Data.List")
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
addFileExtension :: MonadThrow m => PosixString -> Path b File -> m (Path b File)

-- | A synonym for addFileExtension in the form of an infix
--   operator. See more examples there.
--   
--   
--   >>> $(mkRelFile "Data.List") <.> [pstr|symbols|]
--   "Data.List.symbols"
--   
--   >>> $(mkRelFile "Data.List") <.> [pstr|evil/|]
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
(<.>) :: MonadThrow m => Path b File -> PosixString -> m (Path b File)
infixr 7 <.>

-- | Replace/add extension to given file path. Throws if the resulting
--   filename does not parse.

-- | Deprecated: Please use replaceExtension instead.
setFileExtension :: MonadThrow m => PosixString -> Path b File -> m (Path b File)

-- | A synonym for setFileExtension in the form of an operator.

-- | Deprecated: Please use replaceExtension instead.
(-<.>) :: MonadThrow m => Path b File -> PosixString -> m (Path b File)
infixr 7 -<.>
instance GHC.Internal.Data.Data.Data OsPath.Posix.Abs
instance GHC.Internal.Data.Data.Data OsPath.Posix.Dir
instance GHC.Internal.Data.Data.Data OsPath.Posix.File
instance GHC.Internal.Data.Data.Data OsPath.Posix.Rel
instance GHC.Classes.Eq OsPath.Posix.PathException
instance GHC.Classes.Eq (OsPath.Posix.SomeBase t)
instance GHC.Internal.Exception.Type.Exception OsPath.Posix.PathException
instance GHC.Internal.Generics.Generic (OsPath.Posix.SomeBase t)
instance Data.Hashable.Class.Hashable (OsPath.Posix.SomeBase t)
instance Control.DeepSeq.NFData (OsPath.Posix.SomeBase t)
instance GHC.Classes.Ord (OsPath.Posix.SomeBase t)
instance GHC.Internal.Show.Show OsPath.Posix.PathException
instance GHC.Internal.Show.Show (OsPath.Posix.SomeBase t)

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Both Path.Posix and Path.Windows provide the same
--   interface. This module will reexport the appropriate module for your
--   platform.
module OsPath

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Note: This module is for working with Windows style paths.
--   Importing Path is usually better.
--   
--   A path is represented by a number of path components separated by a
--   path separator which is a / on POSIX systems and can be a
--   / or \ on Windows. The root of the tree is
--   represented by a / on POSIX and a drive letter followed by a
--   / or \ on Windows (e.g. C:\). Paths can be
--   absolute or relative. An absolute path always starts from the root of
--   the tree (e.g. /x/y) whereas a relative path never starts
--   with the root (e.g. x/y). Just like we represent the notion
--   of an absolute root by "/", the same way we represent the
--   notion of a relative root by ".". The relative root denotes
--   the directory which contains the first component of a relative path.
module OsPath.Windows

-- | 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 it is a WindowsPath, which 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.
data Path b t

-- | An absolute path.
data Abs

-- | A relative path; one without a root. Note that a .. path
--   component to represent the parent directory is not allowed by this
--   library.
data Rel

-- | A file path.
data File

-- | A directory path.
data Dir

-- | Path of some type. t represents the type, whether file or
--   directory. Pattern match to find whether the path is absolute or
--   relative.
data SomeBase t
Abs :: Path Abs t -> SomeBase t
Rel :: Path Rel t -> SomeBase t

-- | Exceptions that can occur during path operations.
data PathException
InvalidAbsDir :: WindowsPath -> PathException
InvalidRelDir :: WindowsPath -> PathException
InvalidAbsFile :: WindowsPath -> PathException
InvalidRelFile :: WindowsPath -> PathException
InvalidFile :: WindowsPath -> PathException
InvalidDir :: WindowsPath -> PathException
NotAProperPrefix :: WindowsPath -> WindowsPath -> PathException
HasNoExtension :: WindowsPath -> PathException
InvalidExtension :: WindowsString -> PathException

-- | Construct a Path Abs Dir using QuasiQuotes.
--   
--   
--   [absdir|/|]
--   
--   [absdir|/home/chris|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris|] may compile on your platform, but it
--   may not compile on another platform (Windows).
absdir :: QuasiQuoter

-- | Construct a Path Rel Dir using QuasiQuotes.
--   
--   
--   [absdir|/home|]</>[reldir|chris|]
--   
reldir :: QuasiQuoter

-- | Construct a Path Abs File using QuasiQuotes.
--   
--   
--   [absfile|/home/chris/foo.txt|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris/foo.txt|] may compile on your platform,
--   but it may not compile on another platform (Windows).
absfile :: QuasiQuoter

-- | Construct a Path Rel File using QuasiQuotes.
--   
--   
--   [absdir|/home/chris|]</>[relfile|foo.txt|]
--   
relfile :: QuasiQuoter

-- | Append two paths.
--   
--   The following cases are valid and the equalities hold:
--   
--   
--   $(mkAbsDir x) </> $(mkRelDir y) = $(mkAbsDir (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkAbsDir x) </> $(mkRelFile y) = $(mkAbsFile (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkRelDir x) </> $(mkRelDir y) = $(mkRelDir (x <> [pstr|/|] <> y))
--   
--   
--   
--   $(mkRelDir x) </> $(mkRelFile y) = $(mkRelFile (x <> [pstr|/|] <> 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
infixr 5 </>

-- | If the directory in the first argument is a proper prefix of the path
--   in the second argument strip it from the second argument, generating a
--   path relative to the directory. Throws NotAProperPrefix if the
--   directory is not a proper prefix of the path.
--   
--   The following properties hold:
--   
--   
--   stripProperPrefix x (x </> y) = y
--   
--   
--   Cases which are proven not possible:
--   
--   
--   stripProperPrefix (a :: Path Abs …) (b :: Path Rel …)
--   
--   
--   
--   stripProperPrefix (a :: Path Rel …) (b :: Path Abs …)
--   
--   
--   In other words the bases must match.
stripProperPrefix :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | 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)
--   
isProperPrefixOf :: Path b Dir -> Path b t -> Bool

-- | Change from one directory prefix to another.
--   
--   Throw NotAProperPrefix if the first argument is not a proper
--   prefix of the path.
--   
--   
--   >>> replaceProperPrefix $(mkRelDir "foo") $(mkRelDir "bar") $(mkRelFile "foo/file.txt") == $(mkRelFile "bar/file.txt")
--   
replaceProperPrefix :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)

-- | Take the parent path component from a path.
--   
--   The following properties hold:
--   
--   
--   parent (x </> y) == x
--   parent [pstr|/x|] == [pstr|/|]
--   parent [pstr|x|] == [pstr|.|]
--   
--   
--   On the root (absolute or relative), getting the parent is idempotent:
--   
--   
--   parent [pstr|/|] = [pstr|/|]
--   parent [pstr|.|] = [pstr|.|]
--   
parent :: Path b t -> Path b Dir

-- | Extract the file part of a path.
--   
--   The following properties hold:
--   
--   
--   filename (p </> a) == filename a
--   
filename :: Path b File -> Path Rel File

-- | Extract the last directory name of a path.
--   
--   The following properties hold:
--   
--   
--   dirname $(mkRelDir ".") == $(mkRelDir ".")
--   
--   
--   
--   dirname (p </> a) == dirname a
--   
dirname :: Path b Dir -> Path Rel Dir

-- | Add extension to given file path.
--   
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo"    )
--   
--   >>> addExtension [pstr|.foo.|]  $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo."   )
--   
--   >>> addExtension [pstr|.foo..|] $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo.."  )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name.bar" ) == Just $(mkRelFile "name.bar.foo")
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile ".name"    ) == Just $(mkRelFile ".name.foo"   )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "name."    ) == Just $(mkRelFile "name..foo"   )
--   
--   >>> addExtension [pstr|.foo|]   $(mkRelFile "..."      ) == Just $(mkRelFile "....foo"     )
--   
--   
--   Throws an InvalidExtension exception if the extension is not
--   valid. A valid extension starts with a . followed by one or
--   more characters not including . followed by zero or more
--   . in trailing position. Moreover, an extension must be a
--   valid filename, notably it cannot include path separators.
--   Particularly, .foo.bar is an invalid extension, instead you
--   have to first set .foo and then .bar individually.
--   Some examples of invalid extensions are:
--   
--   
--   >>> addExtension [pstr|foo|]      $(mkRelFile "name")
--   
--   >>> addExtension [pstr|..foo|]    $(mkRelFile "name")
--   
--   >>> addExtension [pstr|.foo.bar|] $(mkRelFile "name")
--   
--   >>> addExtension [pstr|.foo/bar|] $(mkRelFile "name")
--   
addExtension :: MonadThrow m => WindowsString -> Path b File -> m (Path b File)

-- | splitExtension is the inverse of addExtension. It splits
--   the given file path into a valid filename and a valid extension.
--   
--   
--   >>> splitExtension $(mkRelFile "name.foo"     ) == Just ($(mkRelFile "name"    ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "name.foo."    ) == Just ($(mkRelFile "name"    ), [pstr|.foo.|] )
--   
--   >>> splitExtension $(mkRelFile "name.foo.."   ) == Just ($(mkRelFile "name"    ), [pstr|.foo..|])
--   
--   >>> splitExtension $(mkRelFile "name.bar.foo" ) == Just ($(mkRelFile "name.bar"), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile ".name.foo"    ) == Just ($(mkRelFile ".name"   ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "name..foo"    ) == Just ($(mkRelFile "name."   ), [pstr|.foo|]  )
--   
--   >>> splitExtension $(mkRelFile "....foo"      ) == Just ($(mkRelFile "..."     ), [pstr|.foo|]  )
--   
--   
--   Throws HasNoExtension exception if the filename does not have
--   an extension or in other words it cannot be split into a valid
--   filename and a valid extension. The following cases throw an
--   exception, please note that "." and ".." are not valid filenames:
--   
--   
--   >>> splitExtension $(mkRelFile "name"   )
--   
--   >>> splitExtension $(mkRelFile "name."  )
--   
--   >>> splitExtension $(mkRelFile "name.." )
--   
--   >>> splitExtension $(mkRelFile ".name"  )
--   
--   >>> splitExtension $(mkRelFile "..name" )
--   
--   >>> splitExtension $(mkRelFile "...name")
--   
--   
--   splitExtension and addExtension are inverses of each
--   other, the following laws hold:
--   
--   
--   uncurry addExtension . swap >=> splitExtension == return
--   splitExtension >=> uncurry addExtension . swap == return
--   
splitExtension :: MonadThrow m => Path b File -> m (Path b File, WindowsString)

-- | Get extension from given file path. Throws HasNoExtension
--   exception if the file does not have an extension. The following laws
--   hold:
--   
--   
--   flip addExtension file >=> fileExtension == return
--   fileExtension == (fmap snd) . splitExtension
--   
fileExtension :: MonadThrow m => Path b File -> m WindowsString

-- | If the file has an extension replace it with the given extension
--   otherwise add the new extension to it. Throws an
--   InvalidExtension exception if the new extension is not a valid
--   extension (see fileExtension for validity rules).
--   
--   The following law holds:
--   
--   
--   (fileExtension >=> flip replaceExtension file) file == return file
--   
replaceExtension :: MonadThrow m => WindowsString -> Path b File -> m (Path b File)

-- | Split an absolute path into a drive and, perhaps, a path. On POSIX,
--   / is a drive.
splitDrive :: Path Abs t -> (Path Abs Dir, Maybe (Path Rel t))

-- | Get the drive from an absolute path. On POSIX, / is a drive.
--   
--   
--   takeDrive x = fst (splitDrive x)
--   
takeDrive :: Path Abs t -> Path Abs Dir

-- | Drop the drive from an absolute path. May result in Nothing if
--   the path is just a drive.
--   
--   
--   dropDrive x = snd (splitDrive x)
--   
dropDrive :: Path Abs t -> Maybe (Path Rel t)

-- | Is an absolute directory path a drive?
isDrive :: Path Abs Dir -> Bool

-- | Helper to apply a function to the SomeBase object
--   
--   
--   >>> mapSomeBase parent (Abs [absfile|/foo/bar/cow.moo|]) == Abs [absdir|/foo/bar|]
--   
mapSomeBase :: (forall b. () => Path b t -> Path b t') -> SomeBase t -> SomeBase t'

-- | Helper to project the contents out of a SomeBase object.
--   
--   
--   >>> prjSomeBase toOsPath (Abs [absfile|/foo/bar/cow.moo|]) == [pstr|/foo/bar/cow.moo|]
--   
prjSomeBase :: (forall b. () => Path b t -> a) -> SomeBase t -> a

-- | Convert an absolute WindowsPath to a normalized absolute dir
--   Path.
--   
--   Throws: InvalidAbsDir when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsDir :: MonadThrow m => WindowsPath -> m (Path Abs Dir)

-- | Convert a relative WindowsPath to a normalized relative dir
--   Path.
--   
--   Throws: InvalidRelDir when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
- is all path separators
--   
parseRelDir :: MonadThrow m => WindowsPath -> m (Path Rel Dir)

-- | Convert an absolute WindowsPath to a normalized absolute file
--   Path.
--   
--   Throws: InvalidAbsFile when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsFile :: MonadThrow m => WindowsPath -> m (Path Abs File)

-- | Convert a relative WindowsPath to a normalized relative file
--   Path.
--   
--   Throws: InvalidRelFile when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseRelFile :: MonadThrow m => WindowsPath -> m (Path Rel File)

-- | Convert an absolute or relative WindowsPath to a normalized
--   SomeBase representing a directory.
--   
--   Throws: InvalidDir when the supplied path:
--   
--   
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeDir :: MonadThrow m => WindowsPath -> m (SomeBase Dir)

-- | Convert an absolute or relative WindowsPath to a normalized
--   SomeBase representing a file.
--   
--   Throws: InvalidFile when the supplied path:
--   
--   
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeFile :: MonadThrow m => WindowsPath -> m (SomeBase File)

-- | Convert to a WindowsPath type.
--   
--   All directories have a trailing slash, so if you want no trailing
--   slash, you can use dropTrailingPathSeparator from the filepath
--   package.
toOsPath :: Path b t -> WindowsPath

-- | Convert absolute path to directory to WindowsPath type.
fromAbsDir :: Path Abs Dir -> WindowsPath

-- | Convert relative path to directory to WindowsPath type.
fromRelDir :: Path Rel Dir -> WindowsPath

-- | Convert absolute path to file to WindowsPath type.
fromAbsFile :: Path Abs File -> WindowsPath

-- | Convert relative path to file to WindowsPath type.
fromRelFile :: Path Rel File -> WindowsPath

-- | Convert a valid path to a WindowsPath.
fromSomeBase :: SomeBase t -> WindowsPath

-- | Convert a valid directory to a WindowsPath.
fromSomeDir :: SomeBase Dir -> WindowsPath

-- | Convert a valid file to a WindowsPath.
fromSomeFile :: SomeBase File -> WindowsPath

-- | 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 :: WindowsPath -> Q Exp

-- | Make a Path Rel Dir.
mkRelDir :: WindowsPath -> 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 :: WindowsPath -> Q Exp

-- | Make a Path Rel File.
mkRelFile :: WindowsPath -> Q Exp

-- | Same as PathException.

-- | Deprecated: Please use PathException instead.
type PathParseException = PathException

-- | Same as stripProperPrefix.

-- | Deprecated: Please use stripProperPrefix instead.
stripDir :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | Same as isProperPrefixOf.

-- | Deprecated: Please use isProperPrefixOf instead.
isParentOf :: Path b Dir -> Path b t -> Bool

-- | Add extension to given file path. Throws if the resulting filename
--   does not parse.
--   
--   
--   >>> addFileExtension [pstr|txt|] $(mkRelFile "foo")
--   "foo.txt"
--   
--   >>> addFileExtension [pstr|symbols|] $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension [pstr|.symbols|] $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension [pstr|symbols|] $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension [pstr|.symbols|] $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension [pstr|evil/|] $(mkRelFile "Data.List")
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
addFileExtension :: MonadThrow m => WindowsString -> Path b File -> m (Path b File)

-- | A synonym for addFileExtension in the form of an infix
--   operator. See more examples there.
--   
--   
--   >>> $(mkRelFile "Data.List") <.> [pstr|symbols|]
--   "Data.List.symbols"
--   
--   >>> $(mkRelFile "Data.List") <.> [pstr|evil/|]
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
(<.>) :: MonadThrow m => Path b File -> WindowsString -> m (Path b File)
infixr 7 <.>

-- | Replace/add extension to given file path. Throws if the resulting
--   filename does not parse.

-- | Deprecated: Please use replaceExtension instead.
setFileExtension :: MonadThrow m => WindowsString -> Path b File -> m (Path b File)

-- | A synonym for setFileExtension in the form of an operator.

-- | Deprecated: Please use replaceExtension instead.
(-<.>) :: MonadThrow m => Path b File -> WindowsString -> m (Path b File)
infixr 7 -<.>
instance GHC.Internal.Data.Data.Data OsPath.Windows.Abs
instance GHC.Internal.Data.Data.Data OsPath.Windows.Dir
instance GHC.Internal.Data.Data.Data OsPath.Windows.File
instance GHC.Internal.Data.Data.Data OsPath.Windows.Rel
instance GHC.Classes.Eq OsPath.Windows.PathException
instance GHC.Classes.Eq (OsPath.Windows.SomeBase t)
instance GHC.Internal.Exception.Type.Exception OsPath.Windows.PathException
instance GHC.Internal.Generics.Generic (OsPath.Windows.SomeBase t)
instance Data.Hashable.Class.Hashable (OsPath.Windows.SomeBase t)
instance Control.DeepSeq.NFData (OsPath.Windows.SomeBase t)
instance GHC.Classes.Ord (OsPath.Windows.SomeBase t)
instance GHC.Internal.Show.Show OsPath.Windows.PathException
instance GHC.Internal.Show.Show (OsPath.Windows.SomeBase t)

-- | Internal types and functions.
module Path.Internal.Posix

-- | 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.
newtype Path b t
Path :: FilePath -> Path b t

-- | Normalized file path representation for the relative path root
relRootFP :: 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.
toFilePath :: Path b t -> FilePath

-- | Helper function: check if the filepath has any parent directories in
--   it. This handles the logic of checking for different path separators
--   on Windows.
hasParentDir :: FilePath -> Bool
isWindows :: Bool
instance (GHC.Internal.Data.Data.Data b, GHC.Internal.Data.Data.Data t) => GHC.Internal.Data.Data.Data (Path.Internal.Posix.Path b t)
instance GHC.Classes.Eq (Path.Internal.Posix.Path b t)
instance GHC.Internal.Generics.Generic (Path.Internal.Posix.Path b t)
instance Data.Hashable.Class.Hashable (Path.Internal.Posix.Path b t)
instance (GHC.Internal.Data.Typeable.Internal.Typeable b, GHC.Internal.Data.Typeable.Internal.Typeable t) => Language.Haskell.TH.Syntax.Lift (Path.Internal.Posix.Path b t)
instance Control.DeepSeq.NFData (Path.Internal.Posix.Path b t)
instance GHC.Classes.Ord (Path.Internal.Posix.Path b t)
instance GHC.Internal.Show.Show (Path.Internal.Posix.Path b t)
instance Data.Aeson.Types.ToJSON.ToJSONKey (Path.Internal.Posix.Path b t)
instance Data.Aeson.Types.ToJSON.ToJSON (Path.Internal.Posix.Path b t)

module Path.Internal

-- | Internal types and functions.
module Path.Internal.Windows

-- | 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.
newtype Path b t
Path :: FilePath -> Path b t

-- | Normalized file path representation for the relative path root
relRootFP :: 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.
toFilePath :: Path b t -> FilePath

-- | Helper function: check if the filepath has any parent directories in
--   it. This handles the logic of checking for different path separators
--   on Windows.
hasParentDir :: FilePath -> Bool
isWindows :: Bool
instance (GHC.Internal.Data.Data.Data b, GHC.Internal.Data.Data.Data t) => GHC.Internal.Data.Data.Data (Path.Internal.Windows.Path b t)
instance GHC.Classes.Eq (Path.Internal.Windows.Path b t)
instance GHC.Internal.Generics.Generic (Path.Internal.Windows.Path b t)
instance Data.Hashable.Class.Hashable (Path.Internal.Windows.Path b t)
instance (GHC.Internal.Data.Typeable.Internal.Typeable b, GHC.Internal.Data.Typeable.Internal.Typeable t) => Language.Haskell.TH.Syntax.Lift (Path.Internal.Windows.Path b t)
instance Control.DeepSeq.NFData (Path.Internal.Windows.Path b t)
instance GHC.Classes.Ord (Path.Internal.Windows.Path b t)
instance GHC.Internal.Show.Show (Path.Internal.Windows.Path b t)
instance Data.Aeson.Types.ToJSON.ToJSONKey (Path.Internal.Windows.Path b t)
instance Data.Aeson.Types.ToJSON.ToJSON (Path.Internal.Windows.Path b t)

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Note: This module is for working with Posix style paths.
--   Importing Path is usually better.
--   
--   A path is represented by a number of path components separated by a
--   path separator which is a / on POSIX systems and can be a
--   / or \ on Windows. The root of the tree is
--   represented by a / on POSIX and a drive letter followed by a
--   / or \ on Windows (e.g. C:\). Paths can be
--   absolute or relative. An absolute path always starts from the root of
--   the tree (e.g. /x/y) whereas a relative path never starts
--   with the root (e.g. x/y). Just like we represent the notion
--   of an absolute root by "/", the same way we represent the
--   notion of a relative root by ".". The relative root denotes
--   the directory which contains the first component of a relative path.
module Path.Posix

-- | 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.
data Path b t

-- | An absolute path.
data Abs

-- | A relative path; one without a root. Note that a .. path
--   component to represent the parent directory is not allowed by this
--   library.
data Rel

-- | A file path.
data File

-- | A directory path.
data Dir

-- | Path of some type. t represents the type, whether file or
--   directory. Pattern match to find whether the path is absolute or
--   relative.
data SomeBase t
Abs :: Path Abs t -> SomeBase t
Rel :: Path Rel t -> SomeBase t

-- | Exceptions that can occur during path operations.
data PathException
InvalidAbsDir :: FilePath -> PathException
InvalidRelDir :: FilePath -> PathException
InvalidAbsFile :: FilePath -> PathException
InvalidRelFile :: FilePath -> PathException
InvalidFile :: FilePath -> PathException
InvalidDir :: FilePath -> PathException
NotAProperPrefix :: FilePath -> FilePath -> PathException
HasNoExtension :: FilePath -> PathException
InvalidExtension :: String -> PathException

-- | Construct a Path Abs Dir using QuasiQuotes.
--   
--   
--   [absdir|/|]
--   
--   [absdir|/home/chris|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris|] may compile on your platform, but it
--   may not compile on another platform (Windows).
absdir :: QuasiQuoter

-- | Construct a Path Rel Dir using QuasiQuotes.
--   
--   
--   [absdir|/home|]</>[reldir|chris|]
--   
reldir :: QuasiQuoter

-- | Construct a Path Abs File using QuasiQuotes.
--   
--   
--   [absfile|/home/chris/foo.txt|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris/foo.txt|] may compile on your platform,
--   but it may not compile on another platform (Windows).
absfile :: QuasiQuoter

-- | Construct a Path Rel File using QuasiQuotes.
--   
--   
--   [absdir|/home/chris|]</>[relfile|foo.txt|]
--   
relfile :: QuasiQuoter

-- | 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
infixr 5 </>

-- | If the directory in the first argument is a proper prefix of the path
--   in the second argument strip it from the second argument, generating a
--   path relative to the directory. Throws NotAProperPrefix if the
--   directory is not a proper prefix of the path.
--   
--   The following properties hold:
--   
--   
--   stripProperPrefix x (x </> y) = y
--   
--   
--   Cases which are proven not possible:
--   
--   
--   stripProperPrefix (a :: Path Abs …) (b :: Path Rel …)
--   
--   
--   
--   stripProperPrefix (a :: Path Rel …) (b :: Path Abs …)
--   
--   
--   In other words the bases must match.
stripProperPrefix :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | 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)
--   
isProperPrefixOf :: Path b Dir -> Path b t -> Bool

-- | Change from one directory prefix to another.
--   
--   Throw NotAProperPrefix if the first argument is not a proper
--   prefix of the path.
--   
--   
--   >>> replaceProperPrefix $(mkRelDir "foo") $(mkRelDir "bar") $(mkRelFile "foo/file.txt") == $(mkRelFile "bar/file.txt")
--   
replaceProperPrefix :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)

-- | 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 "." = "."
--   
parent :: Path b t -> Path b Dir

-- | Extract the file part of a path.
--   
--   The following properties hold:
--   
--   
--   filename (p </> a) == filename a
--   
filename :: Path b File -> Path Rel File

-- | Extract the last directory name of a path.
--   
--   The following properties hold:
--   
--   
--   dirname $(mkRelDir ".") == $(mkRelDir ".")
--   
--   
--   
--   dirname (p </> a) == dirname a
--   
dirname :: Path b Dir -> Path Rel Dir

-- | Add extension to given file path.
--   
--   
--   >>> addExtension ".foo"   $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo"    )
--   
--   >>> addExtension ".foo."  $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo."   )
--   
--   >>> addExtension ".foo.." $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo.."  )
--   
--   >>> addExtension ".foo"   $(mkRelFile "name.bar" ) == Just $(mkRelFile "name.bar.foo")
--   
--   >>> addExtension ".foo"   $(mkRelFile ".name"    ) == Just $(mkRelFile ".name.foo"   )
--   
--   >>> addExtension ".foo"   $(mkRelFile "name."    ) == Just $(mkRelFile "name..foo"   )
--   
--   >>> addExtension ".foo"   $(mkRelFile "..."      ) == Just $(mkRelFile "....foo"     )
--   
--   
--   Throws an InvalidExtension exception if the extension is not
--   valid. A valid extension starts with a . followed by one or
--   more characters not including . followed by zero or more
--   . in trailing position. Moreover, an extension must be a
--   valid filename, notably it cannot include path separators.
--   Particularly, .foo.bar is an invalid extension, instead you
--   have to first set .foo and then .bar individually.
--   Some examples of invalid extensions are:
--   
--   
--   >>> addExtension "foo"      $(mkRelFile "name")
--   
--   >>> addExtension "..foo"    $(mkRelFile "name")
--   
--   >>> addExtension ".foo.bar" $(mkRelFile "name")
--   
--   >>> addExtension ".foo/bar" $(mkRelFile "name")
--   
addExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | splitExtension is the inverse of addExtension. It splits
--   the given file path into a valid filename and a valid extension.
--   
--   
--   >>> splitExtension $(mkRelFile "name.foo"     ) == Just ($(mkRelFile "name"    ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "name.foo."    ) == Just ($(mkRelFile "name"    ), ".foo." )
--   
--   >>> splitExtension $(mkRelFile "name.foo.."   ) == Just ($(mkRelFile "name"    ), ".foo..")
--   
--   >>> splitExtension $(mkRelFile "name.bar.foo" ) == Just ($(mkRelFile "name.bar"), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile ".name.foo"    ) == Just ($(mkRelFile ".name"   ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "name..foo"    ) == Just ($(mkRelFile "name."   ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "....foo"      ) == Just ($(mkRelFile "..."     ), ".foo"  )
--   
--   
--   Throws HasNoExtension exception if the filename does not have
--   an extension or in other words it cannot be split into a valid
--   filename and a valid extension. The following cases throw an
--   exception, please note that "." and ".." are not valid filenames:
--   
--   
--   >>> splitExtension $(mkRelFile "name"   )
--   
--   >>> splitExtension $(mkRelFile "name."  )
--   
--   >>> splitExtension $(mkRelFile "name.." )
--   
--   >>> splitExtension $(mkRelFile ".name"  )
--   
--   >>> splitExtension $(mkRelFile "..name" )
--   
--   >>> splitExtension $(mkRelFile "...name")
--   
--   
--   splitExtension and addExtension are inverses of each
--   other, the following laws hold:
--   
--   
--   uncurry addExtension . swap >=> splitExtension == return
--   splitExtension >=> uncurry addExtension . swap == return
--   
splitExtension :: MonadThrow m => Path b File -> m (Path b File, String)

-- | Get extension from given file path. Throws HasNoExtension
--   exception if the file does not have an extension. The following laws
--   hold:
--   
--   
--   flip addExtension file >=> fileExtension == return
--   fileExtension == (fmap snd) . splitExtension
--   
fileExtension :: MonadThrow m => Path b File -> m String

-- | If the file has an extension replace it with the given extension
--   otherwise add the new extension to it. Throws an
--   InvalidExtension exception if the new extension is not a valid
--   extension (see fileExtension for validity rules).
--   
--   The following law holds:
--   
--   
--   (fileExtension >=> flip replaceExtension file) file == return file
--   
replaceExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | Split an absolute path into a drive and, perhaps, a path. On POSIX,
--   / is a drive.
splitDrive :: Path Abs t -> (Path Abs Dir, Maybe (Path Rel t))

-- | Get the drive from an absolute path. On POSIX, / is a drive.
--   
--   
--   takeDrive x = fst (splitDrive x)
--   
takeDrive :: Path Abs t -> Path Abs Dir

-- | Drop the drive from an absolute path. May result in Nothing if
--   the path is just a drive.
--   
--   
--   dropDrive x = snd (splitDrive x)
--   
dropDrive :: Path Abs t -> Maybe (Path Rel t)

-- | Is an absolute directory path a drive?
isDrive :: Path Abs Dir -> Bool

-- | Helper to apply a function to the SomeBase object
--   
--   
--   >>> mapSomeBase parent (Abs [absfile|/foo/bar/cow.moo|]) == Abs [absdir|"/foo/bar"|]
--   
mapSomeBase :: (forall b. () => Path b t -> Path b t') -> SomeBase t -> SomeBase t'

-- | Helper to project the contents out of a SomeBase object.
--   
--   
--   >>> prjSomeBase toFilePath (Abs [absfile|/foo/bar/cow.moo|]) == "/foo/bar/cow.moo"
--   
prjSomeBase :: (forall b. () => Path b t -> a) -> SomeBase t -> a

-- | Convert an absolute FilePath to a normalized absolute dir
--   Path.
--   
--   Throws: InvalidAbsDir when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir)

-- | Convert a relative FilePath to a normalized relative dir
--   Path.
--   
--   Throws: InvalidRelDir when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
- is all path separators
--   
parseRelDir :: MonadThrow m => FilePath -> m (Path Rel Dir)

-- | Convert an absolute FilePath to a normalized absolute file
--   Path.
--   
--   Throws: InvalidAbsFile when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsFile :: MonadThrow m => FilePath -> m (Path Abs File)

-- | Convert a relative FilePath to a normalized relative file
--   Path.
--   
--   Throws: InvalidRelFile when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseRelFile :: MonadThrow m => FilePath -> m (Path Rel File)

-- | Convert an absolute or relative FilePath to a normalized
--   SomeBase representing a directory.
--   
--   Throws: InvalidDir when the supplied path:
--   
--   
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeDir :: MonadThrow m => FilePath -> m (SomeBase Dir)

-- | Convert an absolute or relative FilePath to a normalized
--   SomeBase representing a file.
--   
--   Throws: InvalidFile when the supplied path:
--   
--   
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeFile :: MonadThrow m => FilePath -> m (SomeBase File)

-- | 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.
toFilePath :: Path b t -> FilePath

-- | Convert absolute path to directory to FilePath type.
fromAbsDir :: Path Abs Dir -> FilePath

-- | Convert relative path to directory to FilePath type.
fromRelDir :: Path Rel Dir -> FilePath

-- | Convert absolute path to file to FilePath type.
fromAbsFile :: Path Abs File -> FilePath

-- | Convert relative path to file to FilePath type.
fromRelFile :: Path Rel File -> FilePath

-- | Convert a valid directory to a FilePath.
fromSomeDir :: SomeBase Dir -> FilePath

-- | Convert a valid file to a FilePath.
fromSomeFile :: SomeBase File -> FilePath

-- | 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

-- | Same as PathException.

-- | Deprecated: Please use PathException instead.
type PathParseException = PathException

-- | Same as stripProperPrefix.

-- | Deprecated: Please use stripProperPrefix instead.
stripDir :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | Same as isProperPrefixOf.

-- | Deprecated: Please use isProperPrefixOf instead.
isParentOf :: Path b Dir -> Path b t -> Bool

-- | Add extension to given file path. Throws if the resulting filename
--   does not parse.
--   
--   
--   >>> addFileExtension "txt $(mkRelFile "foo")
--   "foo.txt"
--   
--   >>> addFileExtension "symbols" $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension ".symbols" $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension "symbols" $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension ".symbols" $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension "evil/" $(mkRelFile "Data.List")
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
addFileExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | A synonym for addFileExtension in the form of an infix
--   operator. See more examples there.
--   
--   
--   >>> $(mkRelFile "Data.List") <.> "symbols"
--   "Data.List.symbols"
--   
--   >>> $(mkRelFile "Data.List") <.> "evil/"
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
(<.>) :: MonadThrow m => Path b File -> String -> m (Path b File)
infixr 7 <.>

-- | Replace/add extension to given file path. Throws if the resulting
--   filename does not parse.

-- | Deprecated: Please use replaceExtension instead.
setFileExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | A synonym for setFileExtension in the form of an operator.

-- | Deprecated: Please use replaceExtension instead.
(-<.>) :: MonadThrow m => Path b File -> String -> m (Path b File)
infixr 7 -<.>
instance GHC.Internal.Data.Data.Data Path.Posix.Abs
instance GHC.Internal.Data.Data.Data Path.Posix.Dir
instance GHC.Internal.Data.Data.Data Path.Posix.File
instance GHC.Internal.Data.Data.Data Path.Posix.Rel
instance GHC.Classes.Eq Path.Posix.PathException
instance GHC.Classes.Eq (Path.Posix.SomeBase t)
instance GHC.Internal.Exception.Type.Exception Path.Posix.PathException
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Posix.Path Path.Posix.Abs Path.Posix.Dir)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Posix.Path Path.Posix.Rel Path.Posix.Dir)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Posix.Path Path.Posix.Abs Path.Posix.File)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Posix.Path Path.Posix.Rel Path.Posix.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Posix.Path Path.Posix.Abs Path.Posix.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Posix.Path Path.Posix.Rel Path.Posix.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Posix.Path Path.Posix.Abs Path.Posix.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Posix.Path Path.Posix.Rel Path.Posix.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Posix.SomeBase Path.Posix.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Posix.SomeBase Path.Posix.File)
instance GHC.Internal.Generics.Generic (Path.Posix.SomeBase t)
instance Data.Hashable.Class.Hashable (Path.Posix.SomeBase t)
instance Control.DeepSeq.NFData (Path.Posix.SomeBase t)
instance GHC.Classes.Ord (Path.Posix.SomeBase t)
instance GHC.Internal.Show.Show Path.Posix.PathException
instance GHC.Internal.Show.Show (Path.Posix.SomeBase t)
instance Data.Aeson.Types.ToJSON.ToJSON (Path.Posix.SomeBase t)

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Both Path.Posix and Path.Windows provide the same
--   interface. This module will reexport the appropriate module for your
--   platform.
module Path

-- | This library provides a well-typed representation of paths in a
--   filesystem directory tree.
--   
--   Note: This module is for working with Windows style paths.
--   Importing Path is usually better.
--   
--   A path is represented by a number of path components separated by a
--   path separator which is a / on POSIX systems and can be a
--   / or \ on Windows. The root of the tree is
--   represented by a / on POSIX and a drive letter followed by a
--   / or \ on Windows (e.g. C:\). Paths can be
--   absolute or relative. An absolute path always starts from the root of
--   the tree (e.g. /x/y) whereas a relative path never starts
--   with the root (e.g. x/y). Just like we represent the notion
--   of an absolute root by "/", the same way we represent the
--   notion of a relative root by ".". The relative root denotes
--   the directory which contains the first component of a relative path.
module Path.Windows

-- | 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.
data Path b t

-- | An absolute path.
data Abs

-- | A relative path; one without a root. Note that a .. path
--   component to represent the parent directory is not allowed by this
--   library.
data Rel

-- | A file path.
data File

-- | A directory path.
data Dir

-- | Path of some type. t represents the type, whether file or
--   directory. Pattern match to find whether the path is absolute or
--   relative.
data SomeBase t
Abs :: Path Abs t -> SomeBase t
Rel :: Path Rel t -> SomeBase t

-- | Exceptions that can occur during path operations.
data PathException
InvalidAbsDir :: FilePath -> PathException
InvalidRelDir :: FilePath -> PathException
InvalidAbsFile :: FilePath -> PathException
InvalidRelFile :: FilePath -> PathException
InvalidFile :: FilePath -> PathException
InvalidDir :: FilePath -> PathException
NotAProperPrefix :: FilePath -> FilePath -> PathException
HasNoExtension :: FilePath -> PathException
InvalidExtension :: String -> PathException

-- | Construct a Path Abs Dir using QuasiQuotes.
--   
--   
--   [absdir|/|]
--   
--   [absdir|/home/chris|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris|] may compile on your platform, but it
--   may not compile on another platform (Windows).
absdir :: QuasiQuoter

-- | Construct a Path Rel Dir using QuasiQuotes.
--   
--   
--   [absdir|/home|]</>[reldir|chris|]
--   
reldir :: QuasiQuoter

-- | Construct a Path Abs File using QuasiQuotes.
--   
--   
--   [absfile|/home/chris/foo.txt|]
--   
--   
--   Remember: due to the nature of absolute paths a path like
--   [absdir|/home/chris/foo.txt|] may compile on your platform,
--   but it may not compile on another platform (Windows).
absfile :: QuasiQuoter

-- | Construct a Path Rel File using QuasiQuotes.
--   
--   
--   [absdir|/home/chris|]</>[relfile|foo.txt|]
--   
relfile :: QuasiQuoter

-- | 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
infixr 5 </>

-- | If the directory in the first argument is a proper prefix of the path
--   in the second argument strip it from the second argument, generating a
--   path relative to the directory. Throws NotAProperPrefix if the
--   directory is not a proper prefix of the path.
--   
--   The following properties hold:
--   
--   
--   stripProperPrefix x (x </> y) = y
--   
--   
--   Cases which are proven not possible:
--   
--   
--   stripProperPrefix (a :: Path Abs …) (b :: Path Rel …)
--   
--   
--   
--   stripProperPrefix (a :: Path Rel …) (b :: Path Abs …)
--   
--   
--   In other words the bases must match.
stripProperPrefix :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | 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)
--   
isProperPrefixOf :: Path b Dir -> Path b t -> Bool

-- | Change from one directory prefix to another.
--   
--   Throw NotAProperPrefix if the first argument is not a proper
--   prefix of the path.
--   
--   
--   >>> replaceProperPrefix $(mkRelDir "foo") $(mkRelDir "bar") $(mkRelFile "foo/file.txt") == $(mkRelFile "bar/file.txt")
--   
replaceProperPrefix :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)

-- | 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 "." = "."
--   
parent :: Path b t -> Path b Dir

-- | Extract the file part of a path.
--   
--   The following properties hold:
--   
--   
--   filename (p </> a) == filename a
--   
filename :: Path b File -> Path Rel File

-- | Extract the last directory name of a path.
--   
--   The following properties hold:
--   
--   
--   dirname $(mkRelDir ".") == $(mkRelDir ".")
--   
--   
--   
--   dirname (p </> a) == dirname a
--   
dirname :: Path b Dir -> Path Rel Dir

-- | Add extension to given file path.
--   
--   
--   >>> addExtension ".foo"   $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo"    )
--   
--   >>> addExtension ".foo."  $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo."   )
--   
--   >>> addExtension ".foo.." $(mkRelFile "name"     ) == Just $(mkRelFile "name.foo.."  )
--   
--   >>> addExtension ".foo"   $(mkRelFile "name.bar" ) == Just $(mkRelFile "name.bar.foo")
--   
--   >>> addExtension ".foo"   $(mkRelFile ".name"    ) == Just $(mkRelFile ".name.foo"   )
--   
--   >>> addExtension ".foo"   $(mkRelFile "name."    ) == Just $(mkRelFile "name..foo"   )
--   
--   >>> addExtension ".foo"   $(mkRelFile "..."      ) == Just $(mkRelFile "....foo"     )
--   
--   
--   Throws an InvalidExtension exception if the extension is not
--   valid. A valid extension starts with a . followed by one or
--   more characters not including . followed by zero or more
--   . in trailing position. Moreover, an extension must be a
--   valid filename, notably it cannot include path separators.
--   Particularly, .foo.bar is an invalid extension, instead you
--   have to first set .foo and then .bar individually.
--   Some examples of invalid extensions are:
--   
--   
--   >>> addExtension "foo"      $(mkRelFile "name")
--   
--   >>> addExtension "..foo"    $(mkRelFile "name")
--   
--   >>> addExtension ".foo.bar" $(mkRelFile "name")
--   
--   >>> addExtension ".foo/bar" $(mkRelFile "name")
--   
addExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | splitExtension is the inverse of addExtension. It splits
--   the given file path into a valid filename and a valid extension.
--   
--   
--   >>> splitExtension $(mkRelFile "name.foo"     ) == Just ($(mkRelFile "name"    ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "name.foo."    ) == Just ($(mkRelFile "name"    ), ".foo." )
--   
--   >>> splitExtension $(mkRelFile "name.foo.."   ) == Just ($(mkRelFile "name"    ), ".foo..")
--   
--   >>> splitExtension $(mkRelFile "name.bar.foo" ) == Just ($(mkRelFile "name.bar"), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile ".name.foo"    ) == Just ($(mkRelFile ".name"   ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "name..foo"    ) == Just ($(mkRelFile "name."   ), ".foo"  )
--   
--   >>> splitExtension $(mkRelFile "....foo"      ) == Just ($(mkRelFile "..."     ), ".foo"  )
--   
--   
--   Throws HasNoExtension exception if the filename does not have
--   an extension or in other words it cannot be split into a valid
--   filename and a valid extension. The following cases throw an
--   exception, please note that "." and ".." are not valid filenames:
--   
--   
--   >>> splitExtension $(mkRelFile "name"   )
--   
--   >>> splitExtension $(mkRelFile "name."  )
--   
--   >>> splitExtension $(mkRelFile "name.." )
--   
--   >>> splitExtension $(mkRelFile ".name"  )
--   
--   >>> splitExtension $(mkRelFile "..name" )
--   
--   >>> splitExtension $(mkRelFile "...name")
--   
--   
--   splitExtension and addExtension are inverses of each
--   other, the following laws hold:
--   
--   
--   uncurry addExtension . swap >=> splitExtension == return
--   splitExtension >=> uncurry addExtension . swap == return
--   
splitExtension :: MonadThrow m => Path b File -> m (Path b File, String)

-- | Get extension from given file path. Throws HasNoExtension
--   exception if the file does not have an extension. The following laws
--   hold:
--   
--   
--   flip addExtension file >=> fileExtension == return
--   fileExtension == (fmap snd) . splitExtension
--   
fileExtension :: MonadThrow m => Path b File -> m String

-- | If the file has an extension replace it with the given extension
--   otherwise add the new extension to it. Throws an
--   InvalidExtension exception if the new extension is not a valid
--   extension (see fileExtension for validity rules).
--   
--   The following law holds:
--   
--   
--   (fileExtension >=> flip replaceExtension file) file == return file
--   
replaceExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | Split an absolute path into a drive and, perhaps, a path. On POSIX,
--   / is a drive.
splitDrive :: Path Abs t -> (Path Abs Dir, Maybe (Path Rel t))

-- | Get the drive from an absolute path. On POSIX, / is a drive.
--   
--   
--   takeDrive x = fst (splitDrive x)
--   
takeDrive :: Path Abs t -> Path Abs Dir

-- | Drop the drive from an absolute path. May result in Nothing if
--   the path is just a drive.
--   
--   
--   dropDrive x = snd (splitDrive x)
--   
dropDrive :: Path Abs t -> Maybe (Path Rel t)

-- | Is an absolute directory path a drive?
isDrive :: Path Abs Dir -> Bool

-- | Helper to apply a function to the SomeBase object
--   
--   
--   >>> mapSomeBase parent (Abs [absfile|/foo/bar/cow.moo|]) == Abs [absdir|"/foo/bar"|]
--   
mapSomeBase :: (forall b. () => Path b t -> Path b t') -> SomeBase t -> SomeBase t'

-- | Helper to project the contents out of a SomeBase object.
--   
--   
--   >>> prjSomeBase toFilePath (Abs [absfile|/foo/bar/cow.moo|]) == "/foo/bar/cow.moo"
--   
prjSomeBase :: (forall b. () => Path b t -> a) -> SomeBase t -> a

-- | Convert an absolute FilePath to a normalized absolute dir
--   Path.
--   
--   Throws: InvalidAbsDir when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsDir :: MonadThrow m => FilePath -> m (Path Abs Dir)

-- | Convert a relative FilePath to a normalized relative dir
--   Path.
--   
--   Throws: InvalidRelDir when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
- is all path separators
--   
parseRelDir :: MonadThrow m => FilePath -> m (Path Rel Dir)

-- | Convert an absolute FilePath to a normalized absolute file
--   Path.
--   
--   Throws: InvalidAbsFile when the supplied path:
--   
--   
--   
- is not an absolute path
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseAbsFile :: MonadThrow m => FilePath -> m (Path Abs File)

-- | Convert a relative FilePath to a normalized relative file
--   Path.
--   
--   Throws: InvalidRelFile when the supplied path:
--   
--   
--   
- is not a relative path
--   
- is ""
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseRelFile :: MonadThrow m => FilePath -> m (Path Rel File)

-- | Convert an absolute or relative FilePath to a normalized
--   SomeBase representing a directory.
--   
--   Throws: InvalidDir when the supplied path:
--   
--   
--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeDir :: MonadThrow m => FilePath -> m (SomeBase Dir)

-- | Convert an absolute or relative FilePath to a normalized
--   SomeBase representing a file.
--   
--   Throws: InvalidFile when the supplied path:
--   
--   
--   
- is a directory path i.e.

- has a trailing path
--   separator
- is . or ends in /.

--   
- contains a .. path component representing the parent
--   directory
--   
- is not a valid path (See isValid)
--   
parseSomeFile :: MonadThrow m => FilePath -> m (SomeBase File)

-- | 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.
toFilePath :: Path b t -> FilePath

-- | Convert absolute path to directory to FilePath type.
fromAbsDir :: Path Abs Dir -> FilePath

-- | Convert relative path to directory to FilePath type.
fromRelDir :: Path Rel Dir -> FilePath

-- | Convert absolute path to file to FilePath type.
fromAbsFile :: Path Abs File -> FilePath

-- | Convert relative path to file to FilePath type.
fromRelFile :: Path Rel File -> FilePath

-- | Convert a valid directory to a FilePath.
fromSomeDir :: SomeBase Dir -> FilePath

-- | Convert a valid file to a FilePath.
fromSomeFile :: SomeBase File -> FilePath

-- | 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

-- | Same as PathException.

-- | Deprecated: Please use PathException instead.
type PathParseException = PathException

-- | Same as stripProperPrefix.

-- | Deprecated: Please use stripProperPrefix instead.
stripDir :: MonadThrow m => Path b Dir -> Path b t -> m (Path Rel t)

-- | Same as isProperPrefixOf.

-- | Deprecated: Please use isProperPrefixOf instead.
isParentOf :: Path b Dir -> Path b t -> Bool

-- | Add extension to given file path. Throws if the resulting filename
--   does not parse.
--   
--   
--   >>> addFileExtension "txt $(mkRelFile "foo")
--   "foo.txt"
--   
--   >>> addFileExtension "symbols" $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension ".symbols" $(mkRelFile "Data.List")
--   "Data.List.symbols"
--   
--   >>> addFileExtension "symbols" $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension ".symbols" $(mkRelFile "Data.List.")
--   "Data.List..symbols"
--   
--   >>> addFileExtension "evil/" $(mkRelFile "Data.List")
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
addFileExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | A synonym for addFileExtension in the form of an infix
--   operator. See more examples there.
--   
--   
--   >>> $(mkRelFile "Data.List") <.> "symbols"
--   "Data.List.symbols"
--   
--   >>> $(mkRelFile "Data.List") <.> "evil/"
--   *** Exception: InvalidRelFile "Data.List.evil/"
--   

-- | Deprecated: Please use addExtension instead.
(<.>) :: MonadThrow m => Path b File -> String -> m (Path b File)
infixr 7 <.>

-- | Replace/add extension to given file path. Throws if the resulting
--   filename does not parse.

-- | Deprecated: Please use replaceExtension instead.
setFileExtension :: MonadThrow m => String -> Path b File -> m (Path b File)

-- | A synonym for setFileExtension in the form of an operator.

-- | Deprecated: Please use replaceExtension instead.
(-<.>) :: MonadThrow m => Path b File -> String -> m (Path b File)
infixr 7 -<.>
instance GHC.Internal.Data.Data.Data Path.Windows.Abs
instance GHC.Internal.Data.Data.Data Path.Windows.Dir
instance GHC.Internal.Data.Data.Data Path.Windows.File
instance GHC.Internal.Data.Data.Data Path.Windows.Rel
instance GHC.Classes.Eq Path.Windows.PathException
instance GHC.Classes.Eq (Path.Windows.SomeBase t)
instance GHC.Internal.Exception.Type.Exception Path.Windows.PathException
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Windows.Path Path.Windows.Abs Path.Windows.Dir)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Windows.Path Path.Windows.Rel Path.Windows.Dir)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Windows.Path Path.Windows.Abs Path.Windows.File)
instance Data.Aeson.Types.FromJSON.FromJSONKey (Path.Internal.Windows.Path Path.Windows.Rel Path.Windows.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Windows.Path Path.Windows.Abs Path.Windows.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Windows.Path Path.Windows.Rel Path.Windows.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Windows.Path Path.Windows.Abs Path.Windows.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Internal.Windows.Path Path.Windows.Rel Path.Windows.File)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Windows.SomeBase Path.Windows.Dir)
instance Data.Aeson.Types.FromJSON.FromJSON (Path.Windows.SomeBase Path.Windows.File)
instance GHC.Internal.Generics.Generic (Path.Windows.SomeBase t)
instance Data.Hashable.Class.Hashable (Path.Windows.SomeBase t)
instance Control.DeepSeq.NFData (Path.Windows.SomeBase t)
instance GHC.Classes.Ord (Path.Windows.SomeBase t)
instance GHC.Internal.Show.Show Path.Windows.PathException
instance GHC.Internal.Show.Show (Path.Windows.SomeBase t)
instance Data.Aeson.Types.ToJSON.ToJSON (Path.Windows.SomeBase t)
