foundation-0.0.30: Alternative prelude with batteries and no dependencies

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

Foundation.VFS.Path

Contents

- Path class

Description

Synopsis

- class Path path where
  - type PathEnt path
  - type PathPrefix path
  - type PathSuffix path
  - (</>) :: path -> PathEnt path -> path
  - splitPath :: path -> (PathPrefix path, [PathEnt path], PathSuffix path)
  - buildPath :: (PathPrefix path, [PathEnt path], PathSuffix path) -> path
- parent :: Path path => path -> path
- filename :: (Path path, Monoid (PathEnt path)) => path -> PathEnt path
- prefix :: Path path => path -> PathPrefix path
- suffix :: Path path => path -> PathSuffix path

# Path class

class Path path where Source #

Path type class

defines the Path associated types and basic functions to implement related to the path manipulation

# TODO, add missing enhancement:

    splitExtension :: PathEnt path -> (PathEnt path, PathEnt path)
    addExtension  :: PathEnt path -> PathEnt path -> PathEnt path
    (.) :: path -> PathEnt path -> path
    (-.) :: path -> PathEnt path -> path

Associated Types

type PathEnt path Source #

the associated PathEntity of the given `path` this type is the minimal element contained in the Path a Path is not a collection but it is possible to see this associated type equivalent to the `Element` type family

type PathPrefix path Source #

the associated prefix of the given `path`

in the case of a `FilePath`, it is a void (i.e. `()`) in the case of a `URI`, it is the schema, host, port...

type PathSuffix path Source #

the associated suffix of the given path

in the case of the `FilePath`, it is a void (i.e. `()`) in the case of the `URI`, it is a the query, the fragment

Methods

(</>) :: path -> PathEnt path -> path Source #

join a path entity to a given path

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

split the path into the associated elements

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

build the path from the associated elements

#### Instances

Instances details

Path FilePath Source # |

Instance details

Defined in Foundation.VFS.FilePath

Associated Types

type PathEnt FilePath Source #

type PathPrefix FilePath Source #

type PathSuffix FilePath Source #

Methods

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

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

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

Path URI Source # |
Instance details Defined in Foundation.VFS.URI Associated Types type PathEnt URI Source # type PathPrefix URI Source # type PathSuffix URI Source # Methods (</>) :: URI -> PathEnt URI -> URI Source # splitPath :: URI -> (PathPrefix URI, [PathEnt URI], PathSuffix URI) Source # buildPath :: (PathPrefix URI, [PathEnt URI], PathSuffix URI) -> URI Source #

parent :: Path path => path -> path Source #

parent is only going to drop the filename.

if you actually want to reference to the parent directory, simply uses:

    parent "." = "." <> ".."

    >>> parent ("foo.hs" :: FilePath)
    .

    >>> parent ("foo/bar/baz.hs" :: FilePath)
    foo/bar

filename :: (Path path, Monoid (PathEnt path)) => path -> PathEnt path Source #

get the filename of the given path

If there is no filename, you will receive the `mempty` of the `PathEnt`

    >>> filename ("foo.hs" :: FilePath)
    foo.hs

    >>> filename ("foo/bar/baz.hs" :: FilePath)
    baz.hs

prefix :: Path path => path -> PathPrefix path Source #

get the path prefix information

    >>> prefix ("/home/tab" :: FilePath)
    Absolute

    >>> prefix ("home/tab" :: FilePath)
    Relative

or for URI (TODO, not yet accurate)

    prefix "http://github.com/vincenthz/hs-foundation?w=1"
       == URISchema http Nothing Nothing "github.com" Nothing

suffix :: Path path => path -> PathSuffix path Source #

get the path suffix information

    >>> suffix ("/home/tab" :: FilePath)
    ()

or for URI (TODO, not yet accurate)

    suffix "http://github.com/vincenthz/hs-foundation?w=1"
       == URISuffix (["w", "1"], Nothing)