data-filepath-2.2.0.0: A type safe file path data structure

Safe HaskellNone
LanguageHaskell2010

Data.FilePath

Contents

Synopsis

Types

data PathSegment Source

A PathSegment is any single element of a path...i.e. the stuff between two '/' characters. Valid path segments cannot contain '/' or control characters. PathSegments are also semigroups to allow concatenating with prefixes/suffixes.

data WeakFilePath a Source

For cases where you dont know during compile time what kind of path you will get, for instance when you are parsing a path from the command line

Instances

Functions

filePathParseError Source

Arguments

:: (String -> NonEmpty String -> a)

A function to handle the case where the some path segments contained invalid characters

-> FilePathParseError 
-> a 

weakFilePath Source

Arguments

:: (FilePath Root a -> b)

The handler for when a Root filepath was found

-> (FilePath Relative a -> b)

The handler for when a Relative filepath was found

-> WeakFilePath a 
-> b 

segString :: PathSegment -> String Source

Every PathSegment is a valid string

mkPathSegment :: String -> Maybe PathSegment Source

Smart constructor for valid PathSegments. Valid path segments cannot contain front slashes or control characters. This function performs all the checks up front.

  • Is the string non-empty?
  • Does the string contain forward slashes or control characters?

parseDirectory :: String -> Either FilePathParseError (WeakFilePath Directory) Source

Takes in a string that is intended to represent a relative path or a root path down the filesystem tree splits on /

parseFilePath :: String -> Either FilePathParseError (WeakFilePath File) Source

Takes in a string that is intended to represent a relative path or a root path down the filesystem tree splits on /

mkDirPath :: String -> Maybe (FilePath Relative Directory) Source

Deprecated: Please use `fmap mkDirPathSeg . mkPathSegment` instead

Smart constructor for directories. Valid directories must be valid PathSegments and also cannot be empty strings.

mkDirPathSeg :: PathSegment -> FilePath Relative Directory Source

This function basically defines what the PathSegment type is semantically. It is string like thing which you can safely create a path from. See mkPathSegment, mkFilePathSeg

mkFilePath :: String -> Maybe (FilePath Relative File) Source

Deprecated: Please use `fmap mkFilePathSeg . mkPathSegment` instead

Smart constructor for files. Valid files must be valid PathSegments and also cannot be empty strings.

Quasi Quoters