Copyright | (c) 2023 Composewell Technologies |
---|---|
License | BSD3 |
Maintainer | streamly@composewell.com |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Streamly.Internal.FileSystem.WindowsPath.Node
Description
This module provides a type safe path append operation by distinguishing
paths between files and directories. Files are represented by the File
WindowsPath
type and directories are represented by the Dir WindowsPath
type.
This distinction provides safety against appending a path to a file. Append
operation allows appending to only Dir
types.
Synopsis
- newtype File a = File a
- newtype Dir a = Dir a
- class IsNode a
- dir :: QuasiQuoter
- file :: QuasiQuoter
- dirE :: String -> Q Exp
- fileE :: String -> Q Exp
- join :: (IsPath WindowsPath (a WindowsPath), IsNode (a WindowsPath)) => Dir WindowsPath -> a WindowsPath -> a WindowsPath
Types
Constructors
File a |
Instances
IsPath WindowsPath (File WindowsPath) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.Node Methods unsafeFromPath :: WindowsPath -> File WindowsPath Source # fromPath :: MonadThrow m => WindowsPath -> m (File WindowsPath) Source # toPath :: File WindowsPath -> WindowsPath Source # | |
IsPath WindowsPath (Rooted (File WindowsPath)) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.SegNode Methods unsafeFromPath :: WindowsPath -> Rooted (File WindowsPath) Source # fromPath :: MonadThrow m => WindowsPath -> m (Rooted (File WindowsPath)) Source # toPath :: Rooted (File WindowsPath) -> WindowsPath Source # | |
IsPath WindowsPath (Unrooted (File WindowsPath)) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.SegNode Methods unsafeFromPath :: WindowsPath -> Unrooted (File WindowsPath) Source # fromPath :: MonadThrow m => WindowsPath -> m (Unrooted (File WindowsPath)) Source # toPath :: Unrooted (File WindowsPath) -> WindowsPath Source # | |
IsNode (File a) Source # | |
Constructors
Dir a |
Instances
IsPath WindowsPath (Dir WindowsPath) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.Node Methods unsafeFromPath :: WindowsPath -> Dir WindowsPath Source # fromPath :: MonadThrow m => WindowsPath -> m (Dir WindowsPath) Source # toPath :: Dir WindowsPath -> WindowsPath Source # | |
IsPath WindowsPath (Rooted (Dir WindowsPath)) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.SegNode Methods unsafeFromPath :: WindowsPath -> Rooted (Dir WindowsPath) Source # fromPath :: MonadThrow m => WindowsPath -> m (Rooted (Dir WindowsPath)) Source # toPath :: Rooted (Dir WindowsPath) -> WindowsPath Source # | |
IsPath WindowsPath (Unrooted (Dir WindowsPath)) Source # | |
Defined in Streamly.Internal.FileSystem.WindowsPath.SegNode Methods unsafeFromPath :: WindowsPath -> Unrooted (Dir WindowsPath) Source # fromPath :: MonadThrow m => WindowsPath -> m (Unrooted (Dir WindowsPath)) Source # toPath :: Unrooted (Dir WindowsPath) -> WindowsPath Source # | |
IsNode (Dir a) Source # | |
Statically Verified Path Literals
Quasiquoters.
dir :: QuasiQuoter Source #
Generates a Dir WindowsPath
type from a quoted literal.
>>>
Path.toString (Path.toPath ([dir|usr|] :: Dir PosixPath))
"usr"
file :: QuasiQuoter Source #
Generates a File WindowsPath
type from a quoted literal.
>>>
Path.toString (Path.toPath ([file|usr|] :: File PosixPath))
"usr"
Statically Verified Path Strings
Template Haskell expression splices.
Operations
join :: (IsPath WindowsPath (a WindowsPath), IsNode (a WindowsPath)) => Dir WindowsPath -> a WindowsPath -> a WindowsPath Source #
Append a Dir
or File
path to a Dir
path.
>>>
Path.toString (Path.toPath (Node.join [dir|/usr|] [dir|bin|] :: Dir PosixPath))
"/usr/bin">>>
Path.toString (Path.toPath (Node.join [dir|/usr|] [file|bin|] :: File PosixPath))
"/usr/bin"
Fails if the second path is a specific location and not a path segment.