-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Support for well-typed paths -- -- Support for well-typed paths, utilizing ByteString under the hood. @package hpath @version 0.10.2 -- | Internal types and functions. module HPath.Internal -- | Path of some base and type. -- -- Internally is a ByteString. The ByteString can be of two formats only: -- --
    --
  1. without trailing path separator: file.txt, -- foo/bar.txt, /foo/bar.txt
  2. --
  3. with trailing path separator: foo/, -- /foo/bar/
  4. --
-- -- There are no duplicate path separators //, no .., no -- ./, no ~/, etc. data Path b MkPath :: ByteString -> Path b instance GHC.Classes.Eq (HPath.Internal.Path b) instance GHC.Classes.Ord (HPath.Internal.Path b) instance GHC.Show.Show (HPath.Internal.Path b) instance Control.DeepSeq.NFData (HPath.Internal.Path b) -- | Support for well-typed paths. module HPath -- | An absolute path. data Abs -- | Path of some base and type. -- -- Internally is a ByteString. The ByteString can be of two formats only: -- --
    --
  1. without trailing path separator: file.txt, -- foo/bar.txt, /foo/bar.txt
  2. --
  3. with trailing path separator: foo/, -- /foo/bar/
  4. --
-- -- There are no duplicate path separators //, no .., no -- ./, no ~/, etc. data Path b -- | A relative path; one without a root. data Rel -- | A filename, without any /. data Fn -- | Exception when parsing a location. data PathParseException data PathException class RelC m pattern Path :: ByteString -> Path a -- | Get a location for an absolute path. Produces a normalised path. -- -- Throws: PathParseException -- --
--   >>> parseAbs "/abc"          :: Maybe (Path Abs)
--   Just "/abc"
--   
--   >>> parseAbs "/"             :: Maybe (Path Abs)
--   Just "/"
--   
--   >>> parseAbs "/abc/def"      :: Maybe (Path Abs)
--   Just "/abc/def"
--   
--   >>> parseAbs "/abc/def/.///" :: Maybe (Path Abs)
--   Just "/abc/def/"
--   
--   >>> parseAbs "abc"           :: Maybe (Path Abs)
--   Nothing
--   
--   >>> parseAbs ""              :: Maybe (Path Abs)
--   Nothing
--   
--   >>> parseAbs "/abc/../foo"   :: Maybe (Path Abs)
--   Nothing
--   
parseAbs :: MonadThrow m => ByteString -> m (Path Abs) -- | Parses a filename. Filenames must not contain slashes. Excludes -- . and '..'. -- -- Throws: PathParseException -- --
--   >>> parseFn "abc"        :: Maybe (Path Fn)
--   Just "abc"
--   
--   >>> parseFn "..."        :: Maybe (Path Fn)
--   Just "..."
--   
--   >>> parseFn "def/"       :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn "abc/def"    :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn "abc/def/."  :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn "/abc"       :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn ""           :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn "abc/../foo" :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn "."          :: Maybe (Path Fn)
--   Nothing
--   
--   >>> parseFn ".."         :: Maybe (Path Fn)
--   Nothing
--   
parseFn :: MonadThrow m => ByteString -> m (Path Fn) -- | Get a location for a relative path. Produces a normalised path. -- -- Note that filepath may contain any number of ./ but -- may not consist solely of ./. It also may not contain a -- single .. anywhere. -- -- Throws: PathParseException -- --
--   >>> parseRel "abc"        :: Maybe (Path Rel)
--   Just "abc"
--   
--   >>> parseRel "def/"       :: Maybe (Path Rel)
--   Just "def/"
--   
--   >>> parseRel "abc/def"    :: Maybe (Path Rel)
--   Just "abc/def"
--   
--   >>> parseRel "abc/def/."  :: Maybe (Path Rel)
--   Just "abc/def/"
--   
--   >>> parseRel "/abc"       :: Maybe (Path Rel)
--   Nothing
--   
--   >>> parseRel ""           :: Maybe (Path Rel)
--   Nothing
--   
--   >>> parseRel "abc/../foo" :: Maybe (Path Rel)
--   Nothing
--   
--   >>> parseRel "."          :: Maybe (Path Rel)
--   Nothing
--   
--   >>> parseRel ".."         :: Maybe (Path Rel)
--   Nothing
--   
parseRel :: MonadThrow m => ByteString -> m (Path Rel) -- | Parses a path, whether it's relative or absolute. Will lose -- information on whether it's relative or absolute. If you need to know, -- reparse it. -- -- Filenames must not contain slashes. Excludes . and '..'. -- -- Throws: PathParseException -- --
--   >>> parseAny "/abc"       :: Maybe (Path a)
--   Just "/abc"
--   
--   >>> parseAny "..."        :: Maybe (Path a)
--   Just "..."
--   
--   >>> parseAny "abc/def"    :: Maybe (Path a)
--   Just "abc/def"
--   
--   >>> parseAny "abc/def/."  :: Maybe (Path a)
--   Just "abc/def/"
--   
--   >>> parseAny "/abc"       :: Maybe (Path a)
--   Just "/abc"
--   
--   >>> parseAny ""           :: Maybe (Path a)
--   Nothing
--   
--   >>> parseAny "abc/../foo" :: Maybe (Path a)
--   Nothing
--   
--   >>> parseAny "."          :: Maybe (Path a)
--   Nothing
--   
--   >>> parseAny ".."         :: Maybe (Path a)
--   Nothing
--   
parseAny :: MonadThrow m => ByteString -> m (Path a) -- | Convert an absolute Path to a ByteString type. fromAbs :: Path Abs -> ByteString -- | Convert a relative Path to a ByteString type. fromRel :: RelC r => Path r -> ByteString -- | Convert any Path to a ByteString type. toFilePath :: Path b -> ByteString -- | Append two paths. -- -- The second argument must always be a relative path, which ensures that -- undefinable things like `"abc" <> "/def"` cannot happen. -- -- Technically, the first argument can be a path that points to a -- non-directory, because this library is IO-agnostic and makes no -- assumptions about file types. -- --
--   >>> (MkPath "/")        </> (MkPath "file"     :: Path Rel)
--   "/file"
--   
--   >>> (MkPath "/path/to") </> (MkPath "file"     :: Path Rel)
--   "/path/to/file"
--   
--   >>> (MkPath "/")        </> (MkPath "file/lal" :: Path Rel)
--   "/file/lal"
--   
--   >>> (MkPath "/")        </> (MkPath "file/"    :: Path Rel)
--   "/file/"
--   
() :: RelC r => Path b -> Path r -> Path b -- | Extract the file part of a path. -- -- The following properties hold: -- --
--   basename (p </> a) == basename a
--   
-- -- Throws: PathException if given the root path "/" -- --
--   >>> basename (MkPath "/abc/def/dod") :: Maybe (Path Fn)
--   Just "dod"
--   
--   >>> basename (MkPath "/abc/def/dod/") :: Maybe (Path Fn)
--   Just "dod"
--   
--   >>> basename (MkPath "/")            :: Maybe (Path Fn)
--   Nothing
--   
basename :: MonadThrow m => Path b -> m (Path Fn) -- | Extract the directory name of a path. -- --
--   >>> dirname (MkPath "/abc/def/dod")
--   "/abc/def"
--   
--   >>> dirname (MkPath "/")
--   "/"
--   
dirname :: Path Abs -> Path Abs -- | Is p a parent of the given location? Implemented in terms of -- stripDir. The bases must match. -- --
--   >>> (MkPath "/lal/lad")     `isParentOf` (MkPath "/lal/lad/fad")
--   True
--   
--   >>> (MkPath "lal/lad")      `isParentOf` (MkPath "lal/lad/fad")
--   True
--   
--   >>> (MkPath "/")            `isParentOf` (MkPath "/")
--   False
--   
--   >>> (MkPath "/lal/lad/fad") `isParentOf` (MkPath "/lal/lad")
--   False
--   
--   >>> (MkPath "fad")          `isParentOf` (MkPath "fad")
--   False
--   
isParentOf :: Path b -> Path b -> Bool -- | Get all parents of a path. -- --
--   >>> getAllParents (MkPath "/abs/def/dod")
--   ["/abs/def","/abs","/"]
--   
--   >>> getAllParents (MkPath "/")
--   []
--   
getAllParents :: Path Abs -> [Path Abs] -- | Strip directory from path, making it relative to that directory. -- Throws Couldn'tStripPrefixDir if directory is not a parent of -- the path. -- -- The bases must match. -- --
--   >>> (MkPath "/lal/lad")     `stripDir` (MkPath "/lal/lad/fad") :: Maybe (Path Rel)
--   Just "fad"
--   
--   >>> (MkPath "lal/lad")      `stripDir` (MkPath "lal/lad/fad")  :: Maybe (Path Rel)
--   Just "fad"
--   
--   >>> (MkPath "/")            `stripDir` (MkPath "/")            :: Maybe (Path Rel)
--   Nothing
--   
--   >>> (MkPath "/lal/lad/fad") `stripDir` (MkPath "/lal/lad")     :: Maybe (Path Rel)
--   Nothing
--   
--   >>> (MkPath "fad")          `stripDir` (MkPath "fad")          :: Maybe (Path Rel)
--   Nothing
--   
stripDir :: MonadThrow m => Path b -> Path b -> m (Path Rel) withAbsPath :: Path Abs -> (ByteString -> IO a) -> IO a withRelPath :: Path Rel -> (ByteString -> IO a) -> IO a withFnPath :: Path Fn -> (ByteString -> IO a) -> IO a -- | Quasiquote an absolute Path. This accepts Unicode Chars and will -- encode as UTF-8. -- --
--   >>> [abs|/etc/profile|] :: Path Abs
--   "/etc/profile"
--   
--   >>> [abs|/|] :: Path Abs
--   "/"
--   
--   >>> [abs|/|] :: Path Abs
--   "/\239\131\144"
--   
abs :: QuasiQuoter -- | Quasiquote a relative Path. This accepts Unicode Chars and will encode -- as UTF-8. -- --
--   >>> [rel|etc|] :: Path Rel
--   "etc"
--   
--   >>> [rel|bar/baz|] :: Path Rel
--   "bar/baz"
--   
--   >>> [rel||] :: Path Rel
--   "\239\131\144"
--   
rel :: QuasiQuoter -- | Quasiquote a file name. This accepts Unicode Chars and will encode as -- UTF-8. -- --
--   >>> [fn|etc|] :: Path Fn
--   "etc"
--   
--   >>> [fn||] :: Path Fn
--   "\239\131\144"
--   
fn :: QuasiQuoter -- | Quasiquote any path (relative or absolute). This accepts Unicode Chars -- and will encode as UTF-8. -- --
--   >>> [any|/etc/profile|] :: Path a
--   "/etc/profile"
--   
--   >>> [any|etc|] :: Path a
--   "etc"
--   
--   >>> [any||] :: Path a
--   "\239\131\144"
--   
any :: QuasiQuoter instance GHC.Show.Show HPath.PathException instance GHC.Show.Show HPath.PathParseException instance HPath.RelC HPath.Rel instance HPath.RelC HPath.Fn instance GHC.Exception.Type.Exception HPath.PathException instance GHC.Exception.Type.Exception HPath.PathParseException instance Language.Haskell.TH.Syntax.Lift (HPath.Internal.Path a)