path-0.6.1: Support for well-typed paths

Safe Haskell | None
Language | Haskell2010

Path.Internal

Description

Internal types and functions.

Synopsis

- newtype Path b t = Path FilePath
- hasParentDir :: FilePath -> Bool
- relRootFP :: FilePath
- toFilePath :: Path b t -> FilePath

# Documentation

newtype Path b t Source #

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:

1. File format: `file.txt`, `foo/bar.txt`, `/foo/bar.txt`
2. Directory format: `foo/`, `/foo/bar/`

All directories end in a trailing separator. There are no duplicate path separators `//`, no `..`, no `./`, no `~/`, etc.

Constructors

Path FilePath |

Instances

Eq (Path b t) Source #

String equality.

The following property holds:

    show x == show y ≡ x == y

Instance details Defined in Path.Internal Methods (==) :: Path b t -> Path b t -> Bool Source # (/=) :: Path b t -> Path b t -> Bool Source #

Ord (Path b t) Source #

String ordering.

The following property holds:

    show x `compare` show y ≡ x `compare` y

Instance details Defined in Path.Internal Methods compare :: Path b t -> Path b t -> Ordering Source # (<) :: Path b t -> Path b t -> Bool Source # (<=) :: Path b t -> Path b t -> Bool Source # (>) :: Path b t -> Path b t -> Bool Source # (>=) :: Path b t -> Path b t -> Bool Source # max :: Path b t -> Path b t -> Path b t Source # min :: Path b t -> Path b t -> Path b t Source #

Show (Path b t) Source #

Same as 'show . Path.toFilePath'.

The following property holds:

    x == y ≡ show x == show y

Instance details Defined in Path.Internal Methods showsPrec :: Int -> Path b t -> ShowS Source # show :: Path b t -> String Source # showList :: [Path b t] -> ShowS Source #
Hashable (Path b t) Source # |
Instance details Defined in Path.Internal Methods hashWithSalt :: Int -> Path b t -> Int Source # hash :: Path b t -> Int Source #
ToJSON (Path b t) Source # |
Instance details Defined in Path.Internal Methods toJSON :: Path b t -> Value Source # toEncoding :: Path b t -> Encoding Source # toJSONList :: [Path b t] -> Value Source # toEncodingList :: [Path b t] -> Encoding Source #
FromJSON (Path Rel Dir) Source # |
Instance details Defined in Path Methods parseJSON :: Value -> Parser (Path Rel Dir) Source # parseJSONList :: Value -> Parser [Path Rel Dir] Source #
FromJSON (Path Rel File) Source # |
Instance details Defined in Path Methods parseJSON :: Value -> Parser (Path Rel File) Source # parseJSONList :: Value -> Parser [Path Rel File] Source #
FromJSON (Path Abs Dir) Source # |
Instance details Defined in Path Methods parseJSON :: Value -> Parser (Path Abs Dir) Source # parseJSONList :: Value -> Parser [Path Abs Dir] Source #
FromJSON (Path Abs File) Source # |
Instance details Defined in Path Methods parseJSON :: Value -> Parser (Path Abs File) Source # parseJSONList :: Value -> Parser [Path Abs File] Source #
NFData (Path b t) Source # |
Instance details Defined in Path.Internal Methods rnf :: Path b t -> () Source #

hasParentDir :: FilePath -> Bool Source #

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

relRootFP :: FilePath Source #

Normalized file path representation for the relative path root

toFilePath :: Path b t -> FilePath Source #

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.