UYC0      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     Safe35=?CeThis class allows selective behaviour for file and directory paths and is mostly for internal use.EhThis class allows selective behaviour for absolute and relative paths and is mostly for internal use.JThis class provides a way to prevent other modules from making further E or C instancesO+This is the main filepath abstract datatype6Invariant - this should always have type :: DirPath arT$Map over the components of the path. R> pathMap (map toLower) "/tmp/Reports/SpreadSheets" == "/tmp/reports/spreadsheets"Currently not exportedCurrently not exportedU Convert the O into a plain !. This is simply an alias for .XUse a  as a O, whose type is determined by its context. > asPath "/tmp" == "/tmp" > asPath "file.txt" == "file.txt" > isAbsolute (asPath "/tmp" :: AbsDir) == True > isAbsolute (asPath "/tmp" :: RelDir) == False > getPathString (asPath "/tmp" :: AbsDir) == "/tmp" > getPathString (asPath "/tmp" :: RelDir) == "tmp"YUse a  as a M. No checking is done. > getPathString (asRelFile "file.txt") == "file.txt" > getPathString (asRelFile "/file.txt") == "file.txt" > getPathString (asRelFile "tmp") == "tmp" > getPathString (asRelFile "/tmp") == "tmp"ZUse a  as a K. No checking is done. > getPathString (asRelDir "file.txt") == "file.txt" > getPathString (asRelDir "/file.txt") == "file.txt" > getPathString (asRelDir "tmp") == "tmp" > getPathString (asRelDir "/tmp") == "tmp"[Use a  as an N. No checking is done. > getPathString (asAbsFile "file.txt") == "/file.txt" > getPathString (asAbsFile "/file.txt") == "/file.txt" > getPathString (asAbsFile "tmp") == "/tmp" > getPathString (asAbsFile "/tmp") == "/tmp"\Use a  as an L. No checking is done. > getPathString (asAbsDir "file.txt") == "/file.txt" > getPathString (asAbsDir "/file.txt") == "/file.txt" > getPathString (asAbsDir "tmp") == "/tmp" > getPathString (asAbsDir "/tmp") == "/tmp"]Use a ( as a 'RelPath fd'. No checking is done.^Use a ) as an 'AbsPath fd'. No checking is done._Use a ) as a 'FilePath ar'. No checking is done.`Use a ( as a 'DirPath ar'. No checking is done.aYExamines the supplied string and constructs an absolute or relative path as appropriate. y> either id (const "fred") (mkPathAbsOrRel "/tmp") == "/tmp" > either id (const "fred") (mkPathAbsOrRel "tmp") == "fred"bPSearches for a file or directory with the supplied path string and returns a Q or PA path as appropriate. If neither exists at the supplied path,  is returned.c Convert a  into an JJ by interpreting it as relative to the supplied directory if necessary. b> mkAbsPath "/tmp" "foo.txt" == "/tmp/foo.txt" > mkAbsPath "/tmp" "/etc/foo.txt" == "/etc/foo.txt"d Convert a  into an J; by interpreting it as relative to the cwd if necessary.emJoin an (absolute or relative) directory path with a relative (file or directory) path to form a new path.fnWe only allow files (and not directories) to have extensions added by this function. This is because it's the vastly common case and an attempt to add one to a directory will - more often than not - represent an error. We don't however want to prevent the corresponding operation on directories, and so we provide a function that is more flexible: .g>Add an extension, even if there is already one there. E.g. -addExtension "foo.txt" "bat" -> "foo.txt.bat". > addExtension "file.txt" "bib" == "file.txt.bib" > addExtension "file." ".bib" == "file..bib" > addExtension "file" ".bib" == "file.bib" > takeFileName (addExtension "" "ext") == ".ext"hmJoin an (absolute or relative) directory path with a relative (file or directory) path to form a new path.i0Remove last extension, and the "." preceding it. +> dropExtension x == fst (splitExtension x)jDrop all extensions )> not $ hasAnExtension (dropExtensions x)l@Set the extension of a file, overwriting one if already present. > replaceExtension "file.txt" ".bob" == "file.bob" > replaceExtension "file.txt" "bob" == "file.bob" > replaceExtension "file" ".bob" == "file.bob" > replaceExtension "file.txt" "" == "file" > replaceExtension "file.fred.bob" "txt" == "file.fred.txt"pSplit on the extension. g is the inverse. > uncurry (<.>) (splitExtension x) == x > uncurry addExtension (splitExtension x) == x > splitExtension "file.txt" == ("file",".txt") > splitExtension "file" == ("file","") > splitExtension "file/file.txt" == ("file/file",".txt") > splitExtension "file.txt/boris" == ("file.txt/boris","") > splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")qSplit on all extensions 5> splitExtensions "file.tar.gz" == ("file",".tar.gz")rPath must not be emptysGet the basename of a file > takeBaseName "/tmp/somedir/myfile.txt" == "myfile" > takeBaseName "./myfile.txt" == "myfile" > takeBaseName "myfile.txt" == "myfile"u%Get the extension of a file, returns "" for no extension, .ext otherwise. > takeExtension x == snd (splitExtension x) > takeExtension (addExtension x "ext") == ".ext" > takeExtension (replaceExtension x "ext") == ".ext"vGet all extensions +> takeExtensions "file.tar.gz" == ".tar.gz"wHGet the filename component of a file path (ie stripping all parent dirs) > takeFileName "/tmp/somedir/myfile.txt" == "myfile.txt" > takeFileName "./myfile.txt" == "myfile.txt" > takeFileName "myfile.txt" == "myfile.txt"x2Check whether two strings are equal as file paths. N> equalFilePath "/tmp/" "/tmp" == True > equalFilePath "/tmp" "tmp" == Falsey Constructs a O from a list of components. > joinPath ["/tmp","someDir","file.txt"] == "/tmp/someDir/file.txt" > (joinPath ["/tmp","someDir","file.txt"] :: RelFile) == "tmp/someDir/file.txt"zCurrently just transforms: <> normalise "/tmp/fred/./jim/./file" == "/tmp/fred/jim/file"{(Deconstructs a path into its components. > splitPath ("/tmp/someDir/myfile.txt" :: AbsDir) == (["tmp","someDir","myfile.txt"],Nothing) > splitPath ("/tmp/someDir/myfile.txt" :: AbsFile) == (["tmp","someDir"],Just "myfile.txt") > splitPath (asAbsFile "/tmp/someDir/myfile.txt") == (["tmp","someDir"],Just "myfile.txt")|SThis function can be used to construct a relative path by removing the supplied L! from the front. It is a runtime  if the supplied J doesn't start with the L. Y> makeRelative "/tmp/somedir" "/tmp/somedir/anotherdir/file.txt" == "anotherdir/file.txt"}UJoins an absolute directory with a relative path to construct a new absolute path. v> makeAbsolute "/tmp" "file.txt" == "/tmp/file.txt" > makeAbsolute "/tmp" "adir/file.txt" == "/tmp/adir/file.txt"~]Converts a relative path into an absolute one by prepending the current working directory.As for }\, but for use when the path may already be absolute (in which case it is left unchanged). :> genericMakeAbsolute "/tmp" (asRelFile "file.txt") == "/tmp/file.txt" > genericMakeAbsolute "/tmp" (asRelFile "adir/file.txt") == "/tmp/adir/file.txt" > genericMakeAbsolute "/tmp" (asAbsFile "adir/file.txt") == "/adir/file.txt" > genericMakeAbsolute "/tmp" (asAbsFile "/adir/file.txt") == "/adir/file.txt"As for ~\, but for use when the path may already be absolute (in which case it is left unchanged).Test whether a O ar fd is absolute. > isAbsolute (asAbsFile "fred") == True > isAbsolute (asRelFile "fred") == False > isAbsolute (asAbsFile "/fred") == True > isAbsolute (asRelFile "/fred") == FalseTest whether the = would correspond to an absolute path if interpreted as a O.7Invariant - this should return True iff arg is of type O Rel _ isRelative = not . isAbsoluteTest whether the < would correspond to a relative path if interpreted as a O. )isRelativeString = not . isAbsoluteString*Does the given filename have an extension? 2> null (takeExtension x) == not (hasAnExtension x)1Does the given filename have the given extension? > hasExtension ".hs" "MyCode.hs" == True > hasExtension ".hs" "MyCode.hs.bak" == False > hasExtension ".hs" "MyCode.bak.hs" == TrueThis is largely for  compatabilityThis is largely for  compatabilityFile extension character > extSeparator == '.'This is largely for  compatabilitydThe character that separates directories. In the case where more than one character is possible,  is the 'ideal' one. > isPathSeparator pathSeparator$The list of all possible separators. %> pathSeparator `elem` pathSeparatorsUThe character that is used to separate the entries in the $PATH environment variable.(Is the character an extension character? )> isExtSeparator a == (a == extSeparator)Rather than using (== )5, use this. Test if something is a path separator. 0> isPathSeparator a == (a `elem` pathSeparators)"Is the character a file separator? 7> isSearchPathSeparator a == (a == searchPathSeparator)#This is a more flexible variant of g / f, which can work with files or directories &> genericAddExtension "/" "x" == "/.x")Allow use of OverloadedStrings if desired}CDEFGHIJKLMNOPQRSTU VWXYZ[\]^_`abcd!"#$efghijklmnopq%r&stuvw'xyz{|}~()*+,-./0123456789:;<UCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~UOSRQPNMLKJIHGEFCDUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~TxCDEFGHIJKLMNOPQRSTU VWXYZ[\]^_`abcd!"#$efghijklmnopq%r&stuvw'xyz{|}~()*+,-./0123456789:;<Safe35=?eThis class allows selective behaviour for file and directory paths and is mostly for internal use.hThis class allows selective behaviour for absolute and relative paths and is mostly for internal use.=JThis class provides a way to prevent other modules from making further  or  instances+This is the main filepath abstract datatype>6Invariant - this should always have type :: DirPath ar$Map over the components of the path. R> pathMap (map toLower) "/tmp/Reports/SpreadSheets" == "/tmp/reports/spreadsheets"?Currently not exported@Currently not exported Convert the  into a plain !. This is simply an alias for .Use a  as a , whose type is determined by its context. > asPath "/tmp" == "/tmp" > asPath "file.txt" == "file.txt" > isAbsolute (asPath "/tmp" :: AbsDir) == True > isAbsolute (asPath "/tmp" :: RelDir) == False > getPathString (asPath "/tmp" :: AbsDir) == "/tmp" > getPathString (asPath "/tmp" :: RelDir) == "tmp"Use a  as a . No checking is done. > getPathString (asRelFile "file.txt") == "file.txt" > getPathString (asRelFile "/file.txt") == "file.txt" > getPathString (asRelFile "tmp") == "tmp" > getPathString (asRelFile "/tmp") == "tmp"Use a  as a . No checking is done. > getPathString (asRelDir "file.txt") == "file.txt" > getPathString (asRelDir "/file.txt") == "file.txt" > getPathString (asRelDir "tmp") == "tmp" > getPathString (asRelDir "/tmp") == "tmp"Use a  as an . No checking is done. > getPathString (asAbsFile "file.txt") == "/file.txt" > getPathString (asAbsFile "/file.txt") == "/file.txt" > getPathString (asAbsFile "tmp") == "/tmp" > getPathString (asAbsFile "/tmp") == "/tmp"Use a  as an . No checking is done. > getPathString (asAbsDir "file.txt") == "/file.txt" > getPathString (asAbsDir "/file.txt") == "/file.txt" > getPathString (asAbsDir "tmp") == "/tmp" > getPathString (asAbsDir "/tmp") == "/tmp"Use a ( as a 'RelPath fd'. No checking is done.Use a ) as an 'AbsPath fd'. No checking is done.Use a ) as a 'FilePath ar'. No checking is done.Use a ( as a 'DirPath ar'. No checking is done.YExamines the supplied string and constructs an absolute or relative path as appropriate. y> either id (const "fred") (mkPathAbsOrRel "/tmp") == "/tmp" > either id (const "fred") (mkPathAbsOrRel "tmp") == "fred"PSearches for a file or directory with the supplied path string and returns a  or A path as appropriate. If neither exists at the supplied path,  is returned. Convert a  into an J by interpreting it as relative to the supplied directory if necessary. b> mkAbsPath "/tmp" "foo.txt" == "/tmp/foo.txt" > mkAbsPath "/tmp" "/etc/foo.txt" == "/etc/foo.txt" Convert a  into an ; by interpreting it as relative to the cwd if necessary.mJoin an (absolute or relative) directory path with a relative (file or directory) path to form a new path.nWe only allow files (and not directories) to have extensions added by this function. This is because it's the vastly common case and an attempt to add one to a directory will - more often than not - represent an error. We don't however want to prevent the corresponding operation on directories, and so we provide a function that is more flexible: .>Add an extension, even if there is already one there. E.g. -addExtension "foo.txt" "bat" -> "foo.txt.bat". > addExtension "file.txt" "bib" == "file.txt.bib" > addExtension "file." ".bib" == "file..bib" > addExtension "file" ".bib" == "file.bib" > takeFileName (addExtension "" "ext") == ".ext"mJoin an (absolute or relative) directory path with a relative (file or directory) path to form a new path.0Remove last extension, and the "." preceding it. +> dropExtension x == fst (splitExtension x)Drop all extensions )> not $ hasAnExtension (dropExtensions x)@Set the extension of a file, overwriting one if already present. > replaceExtension "file.txt" ".bob" == "file.bob" > replaceExtension "file.txt" "bob" == "file.bob" > replaceExtension "file" ".bob" == "file.bob" > replaceExtension "file.txt" "" == "file" > replaceExtension "file.fred.bob" "txt" == "file.fred.txt"Split on the extension.  is the inverse. > uncurry (<.>) (splitExtension x) == x > uncurry addExtension (splitExtension x) == x > splitExtension "file.txt" == ("file",".txt") > splitExtension "file" == ("file","") > splitExtension "file/file.txt" == ("file/file",".txt") > splitExtension "file.txt/boris" == ("file.txt/boris","") > splitExtension "file.txt/boris.ext" == ("file.txt/boris",".ext") > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")Split on all extensions 5> splitExtensions "file.tar.gz" == ("file",".tar.gz")Path must not be emptyGet the basename of a file > takeBaseName "/tmp/somedir/myfile.txt" == "myfile" > takeBaseName "./myfile.txt" == "myfile" > takeBaseName "myfile.txt" == "myfile"%Get the extension of a file, returns "" for no extension, .ext otherwise. > takeExtension x == snd (splitExtension x) > takeExtension (addExtension x "ext") == ".ext" > takeExtension (replaceExtension x "ext") == ".ext"Get all extensions +> takeExtensions "file.tar.gz" == ".tar.gz"HGet the filename component of a file path (ie stripping all parent dirs) > takeFileName "/tmp/somedir/myfile.txt" == "myfile.txt" > takeFileName "./myfile.txt" == "myfile.txt" > takeFileName "myfile.txt" == "myfile.txt"2Check whether two strings are equal as file paths. N> equalFilePath "/tmp/" "/tmp" == True > equalFilePath "/tmp" "tmp" == False Constructs a  from a list of components. > joinPath ["/tmp","someDir","file.txt"] == "/tmp/someDir/file.txt" > (joinPath ["/tmp","someDir","file.txt"] :: RelFile) == "tmp/someDir/file.txt"Currently just transforms: <> normalise "/tmp/fred/./jim/./file" == "/tmp/fred/jim/file"(Deconstructs a path into its components. > splitPath ("/tmp/someDir/myfile.txt" :: AbsDir) == (["tmp","someDir","myfile.txt"],Nothing) > splitPath ("/tmp/someDir/myfile.txt" :: AbsFile) == (["tmp","someDir"],Just "myfile.txt") > splitPath (asAbsFile "/tmp/someDir/myfile.txt") == (["tmp","someDir"],Just "myfile.txt")SThis function can be used to construct a relative path by removing the supplied ! from the front. It is a runtime  if the supplied  doesn't start with the . Y> makeRelative "/tmp/somedir" "/tmp/somedir/anotherdir/file.txt" == "anotherdir/file.txt"UJoins an absolute directory with a relative path to construct a new absolute path. v> makeAbsolute "/tmp" "file.txt" == "/tmp/file.txt" > makeAbsolute "/tmp" "adir/file.txt" == "/tmp/adir/file.txt"]Converts a relative path into an absolute one by prepending the current working directory.As for \, but for use when the path may already be absolute (in which case it is left unchanged). :> genericMakeAbsolute "/tmp" (asRelFile "file.txt") == "/tmp/file.txt" > genericMakeAbsolute "/tmp" (asRelFile "adir/file.txt") == "/tmp/adir/file.txt" > genericMakeAbsolute "/tmp" (asAbsFile "adir/file.txt") == "/adir/file.txt" > genericMakeAbsolute "/tmp" (asAbsFile "/adir/file.txt") == "/adir/file.txt"As for \, but for use when the path may already be absolute (in which case it is left unchanged).Test whether a  ar fd is absolute. > isAbsolute (asAbsFile "fred") == True > isAbsolute (asRelFile "fred") == False > isAbsolute (asAbsFile "/fred") == True > isAbsolute (asRelFile "/fred") == FalseTest whether the = would correspond to an absolute path if interpreted as a .7Invariant - this should return True iff arg is of type  Rel _ isRelative = not . isAbsoluteTest whether the < would correspond to a relative path if interpreted as a . )isRelativeString = not . isAbsoluteString*Does the given filename have an extension? 2> null (takeExtension x) == not (hasAnExtension x)1Does the given filename have the given extension? > hasExtension ".hs" "MyCode.hs" == True > hasExtension ".hs" "MyCode.hs.bak" == False > hasExtension ".hs" "MyCode.bak.hs" == TrueThis is largely for  compatabilityThis is largely for  compatabilityFile extension character > extSeparator == '.'This is largely for  compatabilitydThe character that separates directories. In the case where more than one character is possible,  is the 'ideal' one. > isPathSeparator pathSeparator$The list of all possible separators. %> pathSeparator `elem` pathSeparatorsUThe character that is used to separate the entries in the $PATH environment variable.(Is the character an extension character? )> isExtSeparator a == (a == extSeparator)Rather than using (== )5, use this. Test if something is a path separator. 0> isPathSeparator a == (a `elem` pathSeparators)"Is the character a file separator? 7> isSearchPathSeparator a == (a == searchPathSeparator)#This is a more flexible variant of  / , which can work with files or directories &> genericAddExtension "/" "x" == "/.x"A)Allow use of OverloadedStrings if desired}=BC>DE?@FGHIJKLMNOPQRSTUVWXYAZ[\]^_`abcdUUx=BC>DE?@FGHIJKLMNOPQRSTUVWXYAZ[\]^_`abcdSafeUSafe An alias for .SRetrieve the contents of a directory path (which may be relative) as absolute pathsReturns paths relative toX the supplied (abs or relative) directory path. eg (for current working directory of /somewhere/cwd/): show (relDirectoryContents "d/e/f/") == (["subDir1A","subDir1B"], ["file1A","file1B"])A convenient alternative to  if you only want files.A convenient alternative to  if you only want directories.BBSafe      K  !"#$%&'()*+,-./0123456789:;<=>?@A     K     876543&%$#=<;:!9 'A@?>210"/.-, +)*(      e               ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 678797:7;7<7=7>7?7@7A7BCDCECFCGCHI JKLMNOPOQOROSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~WXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~patht_AKDAOmVBVCwGjebyLnHsznSystem.Path.IOSystem.Path.DirectorySystem.Path.WindowsSystem.Path.PosixSystemFilePath System.Pathbase System.IOprintghc-prim GHC.TypesIOGHC.IO.Handle.TypesHandlefixIOhPrinthReadyreadIOreadLninteract getContentsgetLinegetCharputStrLnputStrputCharGHC.IO.Handle.FDisEOFstderrstdin GHC.IO.HandlehShowhSetBinaryModehIsTerminalDevicehGetEchohSetEcho hIsSeekable hGetBuffering hIsWritable hIsReadable hIsClosedhIsOpenhTellhSeekhSetPosnhGetPosn hSetBuffering hLookAheadhIsEOF hSetFileSize hFileSizehClose HandlePosnGHC.IO.Handle.TexthGetBufNonBlockinghGetBufhPutBufNonBlockinghPutBuf hPutStrLnhPutStrhPutChar hGetContentshGetLinehGetChar hWaitForInput GHC.IO.IOMode ReadWriteMode AppendMode WriteModeReadModeIOModestdouthFlushBlockBuffering LineBuffering NoBuffering BufferMode GHC.IO.Device SeekFromEnd RelativeSeek AbsoluteSeekSeekModedirec_KowvXytSqazBcvN7MGpFtgSystem.Directory Permissions FileDirClassfileDir AbsRelClassabsRelDirPathRelPathAbsPathRelDirAbsDirRelFileAbsFilePathDirFileRelAbspathMap getPathStringrootDir currentDirasPath asRelFileasRelDir asAbsFileasAbsDir asRelPath asAbsPath asFilePath asDirPathmkPathAbsOrRelmkPathFileOrDir mkAbsPathmkAbsPathFromCwd<.> addExtensioncombine dropExtensiondropExtensions dropFileNamereplaceExtensionreplaceBaseNamereplaceDirectoryreplaceFileNamesplitExtensionsplitExtensions splitFileName takeBaseName takeDirectory takeExtensiontakeExtensions takeFileName equalFilePathjoinPath normalise splitPath makeRelative makeAbsolutemakeAbsoluteFromCwdgenericMakeAbsolutegenericMakeAbsoluteFromCwd isAbsoluteisAbsoluteString isRelativeisRelativeStringhasAnExtension hasExtensionaddTrailingPathSeparatordropTrailingPathSeparator extSeparatorhasTrailingPathSeparator pathSeparatorpathSeparatorssearchPathSeparatorisExtSeparatorisPathSeparatorisSearchPathSeparatorgenericAddExtensiongenericDropExtensiongenericDropExtensionsgenericSplitExtensiongenericSplitExtensionsgenericTakeExtensiongenericTakeExtensionscreateDirectorycreateDirectoryIfMissingremoveDirectoryremoveDirectoryRecursiverenameDirectorygetDirectoryContentsabsDirectoryContentsrelDirectoryContents filesInDir dirsInDirgetCurrentDirectorysetCurrentDirectorygetHomeDirectorygetAppUserDataDirectorygetUserDocumentsDirectorygetTemporaryDirectory removeFile renameFilecopyFilecanonicalizePathmakeRelativeToCurrentDirectoryfindExecutable doesFileExistdoesDirectoryExistgetPermissionssetPermissionsgetModificationTimewithFileopenFilereadFile writeFile appendFilewithBinaryFileopenBinaryFile openTempFileopenBinaryTempFilePrivatePathRoot _pathAbsRel _pathFileDirGHC.BaseStringGHC.ShowshowNothingGHC.Errerror$fIsStringPath PathComponentFileDirpcMapprop_asPath_getPathString_isPosix isWindowsmkPathFromComponentsmkPathComponentspathComponents(prop_mkPathFromComponents_pathComponentsprop_splitCombineprop_split_combineprop_takeFileName_end prop_makeAbsoluteFromDir_endSame"prop_makeAbsoluteFromDir_startSame_testallqcFileComponentqcDirComponent qcFilePath qcDirPath$fArbitraryPath$fArbitraryPath0$fArbitraryPathComponent $fReadPath $fShowPath$fFileDirClassDir$fFileDirClassFile$fAbsRelClassRel$fAbsRelClassAbs $fPrivateDir $fPrivateFile $fPrivateRel $fPrivateAbs$fShowPathComponent