streamly-core
Copyright(c) 2023 Composewell Technologies
LicenseBSD3
Maintainerstreamly@composewell.com
PortabilityGHC
Safe HaskellNone
LanguageHaskell2010

Streamly.Internal.FileSystem.PosixPath.SegNode

Description

When Rooted/Unrooted and File/Dir both are present, Rooted/Unrooted must be outermost constructors and File/Dir as inner. Thus the types File (Rooted a) or Dir (Rooted a) are not allowed but Rooted (Dir a) and Rooted (File a) are allowed.

Synopsis

Statically Verified Path Literals

Quasiquoters.

rtdir :: QuasiQuoter Source #

Generates a Rooted (Dir PosixPath) type from a quoted literal.

>>> Path.toString (Path.toPath ([rtdir|/usr|] :: Rooted (Dir PosixPath)))
"/usr"

urdir :: QuasiQuoter Source #

Generates a Unrooted (Dir PosixPath) type from a quoted literal.

>>> Path.toString (Path.toPath ([urdir|usr|] :: Unrooted (Dir PosixPath)))
"usr"

rtfile :: QuasiQuoter Source #

Generates a Rooted (File PosixPath) type from a quoted literal.

>>> Path.toString (Path.toPath ([rtfile|/x.txt|] :: Rooted (File PosixPath)))
"/x.txt"

urfile :: QuasiQuoter Source #

Generates a Unrooted (File PosixPath) type from a quoted literal.

>>> Path.toString (Path.toPath ([urfile|x.txt|] :: Unrooted (File PosixPath)))
"x.txt"

Statically Verified Path Strings

Template Haskell expression splices.

rtdirE :: String -> Q Exp Source #

Generates a Haskell expression of type Rooted (Dir PosixPath).

urdirE :: String -> Q Exp Source #

Generates a Haskell expression of type Unrooted (Dir PosixPath).

rtfileE :: String -> Q Exp Source #

Generates a Haskell expression of type Rooted (File PosixPath).

urfileE :: String -> Q Exp Source #

Generates a Haskell expression of type Unrooted (File PosixPath).

Operations

join :: (IsPath PosixPath (a (Dir PosixPath)), IsPath PosixPath (b PosixPath), IsPath PosixPath (a (b PosixPath))) => a (Dir PosixPath) -> Unrooted (b PosixPath) -> a (b PosixPath) Source #

Append a branch type path to a directory.

>>> Path.toString (Path.toPath (SegNode.join [rtdir|/usr|] [urdir|bin|] :: Rooted (Dir PosixPath)))
"/usr/bin"
>>> Path.toString (Path.toPath (SegNode.join [rtdir|/usr|] [urfile|bin|] :: Rooted (File PosixPath)))
"/usr/bin"
>>> Path.toString (Path.toPath (SegNode.join [urdir|usr|] [urdir|bin|] :: Unrooted (Dir PosixPath)))
"usr/bin"
>>> Path.toString (Path.toPath (SegNode.join [urdir|usr|] [urfile|bin|] :: Unrooted (File PosixPath)))
"usr/bin"

Orphan instances