Loading...

Streamly.Internal.FileSystem.WindowsPath.Seg

This module provides a type safe path append operation by distinguishing paths between rooted paths and branches. Rooted paths are represented by the Rooted WindowsPath type and branches are represented by the Branch WindowsPath type. Rooted paths are paths that are attached to specific roots in the file system. Rooted paths could be absolute or relative e.g. /usr/bin, ./local/bin, or .. Branches are a paths that are not attached to a specific root e.g. usr/bin, local/bin, or ../bin are branches.

This distinction provides a safe path append operation which cannot fail. These types do not allow appending a rooted path to any other path. Only branches can be appended.

Types

class IsSeg a Source #

Constraint to check if a type has Rooted or Branch annotations.

Instances
Instances details
IsSeg (Branch a) Source # 
Instance details

Defined in Streamly.Internal.FileSystem.WindowsPath.Seg

IsSeg (Rooted a) Source # 
Instance details

Defined in Streamly.Internal.FileSystem.WindowsPath.Seg

Statically Verified Path Literals

Quasiquoters.

rt :: QuasiQuoter Source #

Generates a Rooted Path type from a quoted literal.

>>> Path.toString ([rt|/usr|] :: Rooted PosixPath)
"/usr"

br :: QuasiQuoter Source #

Generates a Branch Path type from a quoted literal.

>>> Path.toString ([br|usr|] :: Branch PosixPath)
"usr"

Statically Verified Path Strings

Template Haskell expression splices.

rtE :: String -> Q Exp Source #

Generates a Haskell expression of type Rooted WindowsPath.

brE :: String -> Q Exp Source #

Generates a Haskell expression of type Branch WindowsPath.

Operations

append :: (IsSeg (a WindowsPath), IsPath WindowsPath (a WindowsPath)) => a WindowsPath -> Branch WindowsPath -> a WindowsPath Source #

Append a Branch type path to a Rooted path or Branch path.

>>> Path.toString (Seg.append [rt|/usr|] [br|bin|] :: Rooted PosixPath)
"/usr/bin"
>>> Path.toString (Seg.append [br|usr|] [br|bin|] :: Branch PosixPath)
"usr/bin"