{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
module System.Path.Windows (
Path,
AbsFile, RelFile, AbsDir, RelDir,
Abs, Rel, File, Dir,
AbsRelFile, AbsRelDir, AbsFileDir, RelFileDir,
AbsRel, FileDir, AbsRelFileDir,
AbsPath, RelPath, FilePath, DirPath,
AbsRelPath, FileDirPath,
asPath,
asRelFile, asRelDir, asAbsFile, asAbsDir,
asRelPath, asAbsPath, asFilePath, asDirPath,
path, maybe, maybePath, parse, parsePath,
relFile, relDir, absFile, absDir,
abs, rel, absRel, file, dir, fileDir,
relPath, absPath, filePath, dirPath,
rootDir, currentDir, emptyFile,
toString,
isAbsoluteString, isRelativeString, equalFilePath,
pathSeparator, pathSeparators, isPathSeparator,
Core.extSeparator, Core.isExtSeparator,
Core.searchPathSeparator, Core.isSearchPathSeparator,
addTrailingPathSeparator, dropTrailingPathSeparator,
hasTrailingPathSeparator,
testAll,
) where
import qualified System.Path.RegularExpression as RegEx
import qualified System.Path.Internal.PartClass as Class
import qualified System.Path.Internal as Core
import System.Path.RegularExpression ((-|-))
import Data.Tagged (Tagged(Tagged), untag)
import Data.Char (isAlpha, toLower)
import Data.Monoid (mempty, (<>))
import qualified Test.DocTest.Driver as DocTest
import qualified Test.QuickCheck as QC
import Prelude hiding (FilePath, maybe, abs)
data Windows = Windows
_osDummy :: Windows
_osDummy :: Windows
_osDummy = Windows
Windows
type System = Windows
type Path = Core.Path System
type AbsFile = Core.AbsFile System
type RelFile = Core.RelFile System
type AbsDir = Core.AbsDir System
type RelDir = Core.RelDir System
type AbsRelFile = Core.AbsRelFile System
type AbsRelDir = Core.AbsRelDir System
type AbsFileDir = Core.AbsFileDir System
type RelFileDir = Core.RelFileDir System
type AbsRelFileDir = Core.AbsRelFileDir System
type Abs fd = Core.Abs System fd
type Rel fd = Core.Rel System fd
type File ar = Core.File System ar
type Dir ar = Core.Dir System ar
type AbsRel fd = Core.AbsRel System fd
type FileDir ar = Core.FileDir System ar
type AbsPath fd = Core.AbsPath System fd
type RelPath fd = Core.RelPath System fd
type FilePath ar = Core.FilePath System ar
type DirPath ar = Core.DirPath System ar
type AbsRelPath fd = Core.AbsRelPath System fd
type FileDirPath ar = Core.FileDirPath System ar
{-# DEPRECATED asPath "Use 'maybePath', 'parsePath' or 'path' instead." #-}
asPath :: (Class.AbsOrRel ar, Class.FileOrDir fd) => String -> Path ar fd
asPath :: forall ar fd. (AbsOrRel ar, FileOrDir fd) => String -> Path ar fd
asPath = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Path os ar fd
Core.asPath
{-# DEPRECATED asRelFile "Use 'relFile' instead." #-}
asRelFile :: String -> RelFile
asRelFile :: String -> RelFile
asRelFile = forall os. System os => String -> RelFile os
Core.asRelFile
{-# DEPRECATED asRelDir "Use 'relDir' instead." #-}
asRelDir :: String -> RelDir
asRelDir :: String -> RelDir
asRelDir = forall os. System os => String -> RelDir os
Core.asRelDir
{-# DEPRECATED asAbsFile "Use 'absFile' instead." #-}
asAbsFile :: String -> AbsFile
asAbsFile :: String -> AbsFile
asAbsFile = forall os. System os => String -> AbsFile os
Core.asAbsFile
{-# DEPRECATED asAbsDir "Use 'absDir' instead." #-}
asAbsDir :: String -> AbsDir
asAbsDir :: String -> AbsDir
asAbsDir = forall os. System os => String -> AbsDir os
Core.asAbsDir
{-# DEPRECATED asRelPath "Use 'relPath' instead." #-}
asRelPath :: (Class.FileOrDir fd) => String -> RelPath fd
asRelPath :: forall fd. FileOrDir fd => String -> RelPath fd
asRelPath = forall os fd. (System os, FileDir fd) => String -> RelPath os fd
Core.asRelPath
{-# DEPRECATED asAbsPath "Use 'absPath' instead." #-}
asAbsPath :: (Class.FileOrDir fd) => String -> AbsPath fd
asAbsPath :: forall fd. FileOrDir fd => String -> AbsPath fd
asAbsPath = forall os fd. (System os, FileDir fd) => String -> AbsPath os fd
Core.asAbsPath
{-# DEPRECATED asFilePath "Use 'filePath' instead." #-}
asFilePath :: (Class.AbsOrRel ar) => String -> FilePath ar
asFilePath :: forall ar. AbsOrRel ar => String -> FilePath ar
asFilePath = forall os ar. (System os, AbsRel ar) => String -> FilePath os ar
Core.asFilePath
{-# DEPRECATED asDirPath "Use 'dirPath' instead." #-}
asDirPath :: (Class.AbsOrRel ar) => String -> DirPath ar
asDirPath :: forall ar. AbsOrRel ar => String -> DirPath ar
asDirPath = forall os ar. (System os, AbsRel ar) => String -> DirPath os ar
Core.asDirPath
{-# DEPRECATED maybePath "Use Path.maybe instead." #-}
{-# DEPRECATED parsePath "Use Path.parse instead." #-}
maybe, maybePath ::
(Class.AbsRel ar, Class.FileDir fd) => String -> Maybe (Path ar fd)
maybe :: forall ar fd.
(AbsRel ar, FileDir fd) =>
String -> Maybe (Path ar fd)
maybe = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Maybe (Path os ar fd)
Core.maybe
maybePath :: forall ar fd.
(AbsRel ar, FileDir fd) =>
String -> Maybe (Path ar fd)
maybePath = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Maybe (Path os ar fd)
Core.maybe
parse, parsePath ::
(Class.AbsRel ar, Class.FileDir fd) => String -> Either String (Path ar fd)
parse :: forall ar fd.
(AbsRel ar, FileDir fd) =>
String -> Either String (Path ar fd)
parse = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Either String (Path os ar fd)
Core.parse
parsePath :: forall ar fd.
(AbsRel ar, FileDir fd) =>
String -> Either String (Path ar fd)
parsePath = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Either String (Path os ar fd)
Core.parse
path :: (Class.AbsRel ar, Class.FileDir fd) => String -> Path ar fd
path :: forall ar fd. (AbsRel ar, FileDir fd) => String -> Path ar fd
path = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
String -> Path os ar fd
Core.path
relFile :: String -> RelFile
relFile :: String -> RelFile
relFile = forall os. System os => String -> RelFile os
Core.relFile
relDir :: String -> RelDir
relDir :: String -> RelDir
relDir = forall os. System os => String -> RelDir os
Core.relDir
absFile :: String -> AbsFile
absFile :: String -> AbsFile
absFile = forall os. System os => String -> AbsFile os
Core.absFile
absDir :: String -> AbsDir
absDir :: String -> AbsDir
absDir = forall os. System os => String -> AbsDir os
Core.absDir
rel :: (Class.FileDir fd) => String -> Rel fd
rel :: forall fd. FileDir fd => String -> Rel fd
rel = forall os fd. (System os, FileDir fd) => String -> RelPath os fd
Core.rel
abs :: (Class.FileDir fd) => String -> Abs fd
abs :: forall fd. FileDir fd => String -> Abs fd
abs = forall os fd. (System os, FileDir fd) => String -> AbsPath os fd
Core.abs
absRel :: (Class.FileDir fd) => String -> AbsRel fd
absRel :: forall fd. FileDir fd => String -> AbsRel fd
absRel = forall os fd. (System os, FileDir fd) => String -> AbsRel os fd
Core.absRel
file :: (Class.AbsRel ar) => String -> File ar
file :: forall ar. AbsRel ar => String -> File ar
file = forall os ar. (System os, AbsRel ar) => String -> FilePath os ar
Core.file
dir :: (Class.AbsRel ar) => String -> Dir ar
dir :: forall ar. AbsRel ar => String -> Dir ar
dir = forall os ar. (System os, AbsRel ar) => String -> DirPath os ar
Core.dir
fileDir :: (Class.AbsRel ar) => String -> FileDir ar
fileDir :: forall ar. AbsRel ar => String -> FileDir ar
fileDir = forall os ar. (System os, AbsRel ar) => String -> FileDir os ar
Core.fileDir
relPath :: (Class.FileDir fd) => String -> RelPath fd
relPath :: forall fd. FileDir fd => String -> Rel fd
relPath = forall os fd. (System os, FileDir fd) => String -> RelPath os fd
Core.relPath
absPath :: (Class.FileDir fd) => String -> AbsPath fd
absPath :: forall fd. FileDir fd => String -> Abs fd
absPath = forall os fd. (System os, FileDir fd) => String -> AbsPath os fd
Core.absPath
filePath :: (Class.AbsRel ar) => String -> FilePath ar
filePath :: forall ar. AbsRel ar => String -> File ar
filePath = forall os ar. (System os, AbsRel ar) => String -> FilePath os ar
Core.filePath
dirPath :: (Class.AbsRel ar) => String -> DirPath ar
dirPath :: forall ar. AbsRel ar => String -> Dir ar
dirPath = forall os ar. (System os, AbsRel ar) => String -> DirPath os ar
Core.dirPath
rootDir :: AbsDir
rootDir :: AbsDir
rootDir = forall os. System os => AbsDir os
Core.rootDir
currentDir :: RelDir
currentDir :: RelDir
currentDir = forall os. System os => RelDir os
Core.currentDir
emptyFile :: RelFile
emptyFile :: RelFile
emptyFile = forall os. System os => RelFile os
Core.emptyFile
toString :: (Class.AbsRel ar, Class.FileDir fd) => Path ar fd -> String
toString :: forall ar fd. (AbsRel ar, FileDir fd) => Path ar fd -> String
toString = forall os ar fd.
(System os, AbsRel ar, FileDir fd) =>
Path os ar fd -> String
Core.toString
instance Core.System Windows where
pathSeparator :: Tagged Windows Char
pathSeparator = forall {k} (s :: k) b. b -> Tagged s b
Tagged Char
pathSeparator
splitAbsolute :: Tagged Windows (State String String)
splitAbsolute = forall {k} (s :: k) b. b -> Tagged s b
Tagged forall a b. (a -> b) -> a -> b
$ forall a. Parser a -> State [a] [a]
RegEx.run forall a b. (a -> b) -> a -> b
$
forall a. (a -> Bool) -> Parser a
RegEx.single Char -> Bool
isPathSeparator
forall a. Parser a -> Parser a -> Parser a
-|-
Parser Char
driveRegEx forall a. Semigroup a => a -> a -> a
<> (forall a. (a -> Bool) -> Parser a
RegEx.single Char -> Bool
isPathSeparator forall a. Parser a -> Parser a -> Parser a
-|- forall a. Monoid a => a
mempty)
canonicalize :: Tagged Windows (String -> String)
canonicalize = forall {k} (s :: k) b. b -> Tagged s b
Tagged forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower
splitDrive :: Tagged Windows (State String String)
splitDrive = forall {k} (s :: k) b. b -> Tagged s b
Tagged forall a b. (a -> b) -> a -> b
$ forall a. Parser a -> State [a] [a]
RegEx.run Parser Char
driveRegEx
genDrive :: Tagged Windows (Gen String)
genDrive = forall {k} (s :: k) b. b -> Tagged s b
Tagged forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> [a] -> [a]
:String
":") forall a b. (a -> b) -> a -> b
$ forall a. Random a => (a, a) -> Gen a
QC.choose (Char
'a', Char
'z')
driveRegEx :: RegEx.Parser Char
driveRegEx :: Parser Char
driveRegEx = forall a. (a -> Bool) -> Parser a
RegEx.single Char -> Bool
isAlpha forall a. Semigroup a => a -> a -> a
<> forall a. (a -> Bool) -> Parser a
RegEx.single (Char
':'forall a. Eq a => a -> a -> Bool
==)
withOS :: Tagged System a -> a
withOS :: forall a. Tagged Windows a -> a
withOS = forall {k} (s :: k) b. Tagged s b -> b
untag
{-# DEPRECATED equalFilePath "Use System.FilePath.equalFilePath instead." #-}
{-# DEPRECATED isAbsoluteString "Use System.FilePath.isAbsolute instead." #-}
{-# DEPRECATED isRelativeString "Use System.FilePath.isRelative instead." #-}
equalFilePath :: String -> String -> Bool
equalFilePath :: String -> String -> Bool
equalFilePath = forall a. Tagged Windows a -> a
withOS forall os. System os => Tagged os (String -> String -> Bool)
Core.equalFilePath
isAbsoluteString :: String -> Bool
isAbsoluteString :: String -> Bool
isAbsoluteString = forall a. Tagged Windows a -> a
withOS forall os. System os => Tagged os (String -> Bool)
Core.isAbsoluteString
isRelativeString :: String -> Bool
isRelativeString :: String -> Bool
isRelativeString = forall a. Tagged Windows a -> a
withOS forall os. System os => Tagged os (String -> Bool)
Core.isRelativeString
pathSeparator :: Char
pathSeparator :: Char
pathSeparator = Char
'\\'
pathSeparators :: [Char]
pathSeparators :: String
pathSeparators = forall a. Tagged Windows a -> a
withOS forall os. System os => Tagged os String
Core.pathSeparators
isPathSeparator :: Char -> Bool
isPathSeparator :: Char -> Bool
isPathSeparator = forall a. Tagged Windows a -> a
withOS forall os. System os => Tagged os (Char -> Bool)
Core.isPathSeparator
{-# DEPRECATED addTrailingPathSeparator "Use System.FilePath.addTrailingPathSeparator instead." #-}
{-# DEPRECATED dropTrailingPathSeparator "Use System.FilePath.dropTrailingPathSeparator instead." #-}
{-# DEPRECATED hasTrailingPathSeparator "Use System.FilePath.hasTrailingPathSeparator instead." #-}
addTrailingPathSeparator :: String -> String
addTrailingPathSeparator :: String -> String
addTrailingPathSeparator = (forall a. [a] -> [a] -> [a]
++[Char
pathSeparator])
dropTrailingPathSeparator :: String -> String
dropTrailingPathSeparator :: String -> String
dropTrailingPathSeparator = forall a. [a] -> [a]
init
hasTrailingPathSeparator :: String -> Bool
hasTrailingPathSeparator :: String -> Bool
hasTrailingPathSeparator = Char -> Bool
isPathSeparator forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> a
last
testAll :: [(String, DocTest.T ())]
testAll :: [(String, T ())]
testAll = forall os. System os => os -> [(String, T ())]
Core.testAll Windows
Windows