Loading...

Streamly.Internal.FileSystem.PosixPath.Node

This module provides a type safe path append operation by distinguishing paths between files and directories. Files are represented by the File PosixPath type and directories are represented by the Dir PosixPath type.

This distinction provides safety against appending a path to a file. Append operation allows appending to only Dir types.

Types

class IsNode a Source #

Constraint to check if a type uses File or Dir as the outermost constructor.

Instances
Instances details
IsNode (Dir a) Source # 
Instance details

Defined in Streamly.Internal.FileSystem.PosixPath.Node

IsNode (File a) Source # 
Instance details

Defined in Streamly.Internal.FileSystem.PosixPath.Node

Statically Verified Path Literals

Quasiquoters.

dir :: QuasiQuoter Source #

Generates a Dir PosixPath type from a quoted literal.

>>> Path.toString ([dir|usr|] :: Dir PosixPath)
"usr"

file :: QuasiQuoter Source #

Generates a File PosixPath type from a quoted literal.

>>> Path.toString ([file|usr|] :: File PosixPath)
"usr"

Statically Verified Path Strings

Template Haskell expression splices.

dirE :: String -> Q Exp Source #

Generates a Haskell expression of type Dir PosixPath.

fileE :: String -> Q Exp Source #

Generates a Haskell expression of type File PosixPath.

Operations

append :: (IsPath PosixPath (a PosixPath), IsNode (a PosixPath)) => Dir PosixPath -> a PosixPath -> a PosixPath Source #

Append a Dir or File path to a Dir path.

>>> Path.toString (Node.append [dir|/usr|] [dir|bin|] :: Dir PosixPath)
"/usr/bin"
>>> Path.toString (Node.append [dir|/usr|] [file|bin|] :: File PosixPath)
"/usr/bin"

Fails if the second path is a specific location and not a path segment.