foundation-0.0.30: Alternative prelude with batteries and no dependencies

License | BSD-style
Maintainer | foundation
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Foundation.VFS.FilePath

Contents

- conversion
  - unsafe

Description

# Opaque implementation for FilePath

The underlying type of a FilePath is a `ByteArray`. It is indeed like this because for some systems (Unix systems) a `FilePath` is a null terminated array of bytes.

# FilePath and FileName for type checking validation

In order to add some constraint at compile time, it is not possible to append (`</>`) a `FilePath` to another `FilePath`. You can only append (`</>`) a `FileName` to a given `FilePath`.

Synopsis

- data FilePath
- data Relativity
  - = Absolute
  - | Relative
- data FileName
- filePathToString :: FilePath -> String
- filePathToLString :: FilePath -> [Char]
- unsafeFilePath :: Relativity -> [FileName] -> FilePath
- unsafeFileName :: UArray Word8 -> FileName
- extension :: FileName -> Maybe FileName

# Documentation

data FilePath #

FilePath is a collection of FileName

TODO: Eq and Ord are implemented using Show This is not very efficient and would need to be improved Also, it is possible the ordering is not necessary what we want in this case.

A FilePath is one of the following:

- An Absolute:
- starts with one of the follwing "/"
- A relative:
- don't start with a "/"
- authorised:
- "/"
- "filepath"
- "."
- ".."
- "workhaskellhs-foundation"
- unauthorised
- "path//"

#### Instances

Instances details

Path FilePath # |

Instance details

Defined in Foundation.VFS.FilePath

Associated Types

type PathEnt FilePath |
Instance details Defined in Foundation.VFS.FilePath type PathEnt FilePath = FileName
type PathPrefix FilePath |
Instance details Defined in Foundation.VFS.FilePath type PathPrefix FilePath = Relativity
type PathSuffix FilePath |
Instance details Defined in Foundation.VFS.FilePath type PathSuffix FilePath = ()

Methods

(</>) :: FilePath -> PathEnt FilePath -> FilePath #

splitPath :: FilePath -> (PathPrefix FilePath, [PathEnt FilePath], PathSuffix FilePath) #

buildPath :: (PathPrefix FilePath, [PathEnt FilePath], PathSuffix FilePath) -> FilePath #

IsString FilePath # |
Instance details Defined in Foundation.VFS.FilePath Methods fromString :: String -> FilePath #
Show FilePath # |
Instance details Defined in Foundation.VFS.FilePath Methods showsPrec :: Int -> FilePath -> ShowS # show :: FilePath -> String # showList :: [FilePath] -> ShowS #
Eq FilePath # |
Instance details Defined in Foundation.VFS.FilePath Methods (==) :: FilePath -> FilePath -> Bool # (/=) :: FilePath -> FilePath -> Bool #
Ord FilePath # |
Instance details Defined in Foundation.VFS.FilePath Methods compare :: FilePath -> FilePath -> Ordering # (<) :: FilePath -> FilePath -> Bool # (<=) :: FilePath -> FilePath -> Bool # (>) :: FilePath -> FilePath -> Bool # (>=) :: FilePath -> FilePath -> Bool # max :: FilePath -> FilePath -> FilePath # min :: FilePath -> FilePath -> FilePath #
type PathEnt FilePath # |
Instance details Defined in Foundation.VFS.FilePath type PathEnt FilePath = FileName
type PathPrefix FilePath # |
Instance details Defined in Foundation.VFS.FilePath type PathPrefix FilePath = Relativity
type PathSuffix FilePath # |
Instance details Defined in Foundation.VFS.FilePath type PathSuffix FilePath = ()

data Relativity #

information about type of FilePath

A file path being only `Relative` or `Absolute`.

Constructors

Absolute |
Relative |

#### Instances

Instances details

Show Relativity # |
Instance details Defined in Foundation.VFS.FilePath Methods showsPrec :: Int -> Relativity -> ShowS # show :: Relativity -> String # showList :: [Relativity] -> ShowS #
Eq Relativity # |
Instance details Defined in Foundation.VFS.FilePath Methods (==) :: Relativity -> Relativity -> Bool # (/=) :: Relativity -> Relativity -> Bool #

data FileName #

A filename (or path entity) in the FilePath

- Authorised
- ""
- "."
- ".."
- "foundation"
- Unauthorised
- "/"
- "file/"
- "/file"
- "file/path"

#### Instances

Instances details

Monoid FileName # |
Instance details Defined in Foundation.VFS.FilePath Methods mempty :: FileName # mappend :: FileName -> FileName -> FileName # mconcat :: [FileName] -> FileName #
Semigroup FileName # |
Instance details Defined in Foundation.VFS.FilePath Methods (<>) :: FileName -> FileName -> FileName # sconcat :: NonEmpty FileName -> FileName # stimes :: Integral b => b -> FileName -> FileName #
IsString FileName # |
Instance details Defined in Foundation.VFS.FilePath Methods fromString :: String -> FileName #
Show FileName # |
Instance details Defined in Foundation.VFS.FilePath Methods showsPrec :: Int -> FileName -> ShowS # show :: FileName -> String # showList :: [FileName] -> ShowS #
Eq FileName # |
Instance details Defined in Foundation.VFS.FilePath Methods (==) :: FileName -> FileName -> Bool # (/=) :: FileName -> FileName -> Bool #

# conversion

filePathToString :: FilePath -> String #

filePathToLString :: FilePath -> [Char] #

conversion of a FilePath into a list of Char

this function may throw exceptions

## unsafe

unsafeFilePath :: Relativity -> [FileName] -> FilePath #

build a file path from a given list of filename

this is unsafe and is mainly needed for testing purpose

unsafeFileName :: UArray Word8 -> FileName #

build a file name from a given ByteArray

this is unsafe and is mainly needed for testing purpose

extension :: FileName -> Maybe FileName #