Copyright | (c) 2009 Holger Siegel 2013 - 2014 Björn Peemöller 2018 Kai-Oliver Prott |
---|---|
License | BSD-3-clause |
Maintainer | fte@informatik.uni-kiel.de |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
The functions in this module were collected from several compiler modules in order to provide a unique accessing point for this functionality.
Synopsis
- type FilePath = String
- takeBaseName :: FilePath -> String
- dropExtension :: FilePath -> FilePath
- takeExtension :: FilePath -> String
- takeFileName :: FilePath -> FilePath
- moduleNameToFile :: ModuleIdent -> FilePath
- fileNameToModule :: FilePath -> ModuleIdent
- splitModuleFileName :: ModuleIdent -> FilePath -> (FilePath, FilePath)
- isCurryFilePath :: String -> Bool
- currySubdir :: String
- hasCurrySubdir :: FilePath -> Bool
- addCurrySubdir :: Bool -> FilePath -> FilePath
- addCurrySubdirModule :: Bool -> ModuleIdent -> FilePath -> FilePath
- ensureCurrySubdir :: FilePath -> FilePath
- curryExt :: String
- lcurryExt :: String
- icurryExt :: String
- typedFlatExt :: String
- flatExt :: String
- flatIntExt :: String
- acyExt :: String
- uacyExt :: String
- sourceRepExt :: String
- sourceExts :: [String]
- moduleExts :: [String]
- interfName :: FilePath -> FilePath
- typedFlatName :: FilePath -> FilePath
- typeAnnFlatName :: FilePath -> FilePath
- flatName :: FilePath -> FilePath
- flatIntName :: FilePath -> FilePath
- acyName :: FilePath -> FilePath
- uacyName :: FilePath -> FilePath
- sourceRepName :: FilePath -> FilePath
- tokensName :: FilePath -> FilePath
- commentsName :: FilePath -> FilePath
- astName :: FilePath -> FilePath
- shortASTName :: FilePath -> FilePath
- htmlName :: ModuleIdent -> String
Re-exports from FilePath
File and directory names are values of type String
, whose precise
meaning is operating system dependent. Files can be opened, yielding a
handle which can then be used to operate on the contents of that file.
takeBaseName :: FilePath -> String #
Get the base name, without an extension or path.
takeBaseName "/directory/file.ext" == "file" takeBaseName "file/test.txt" == "test" takeBaseName "dave.ext" == "dave" takeBaseName "" == "" takeBaseName "test" == "test" takeBaseName (addTrailingPathSeparator x) == "" takeBaseName "file/file.tar.gz" == "file.tar"
dropExtension :: FilePath -> FilePath #
Remove last extension, and the "." preceding it.
dropExtension "/directory/path.ext" == "/directory/path" dropExtension x == fst (splitExtension x)
takeExtension :: FilePath -> String #
Get the extension of a file, returns ""
for no extension, .ext
otherwise.
takeExtension "/directory/path.ext" == ".ext" takeExtension x == snd (splitExtension x) Valid x => takeExtension (addExtension x "ext") == ".ext" Valid x => takeExtension (replaceExtension x "ext") == ".ext"
takeFileName :: FilePath -> FilePath #
Get the file name.
takeFileName "/directory/file.ext" == "file.ext" takeFileName "test/" == "" takeFileName x `isSuffixOf` x takeFileName x == snd (splitFileName x) Valid x => takeFileName (replaceFileName x "fred") == "fred" Valid x => takeFileName (x </> "fred") == "fred" Valid x => isRelative (takeFileName x)
Conversion between ModuleIdent
and FilePath
moduleNameToFile :: ModuleIdent -> FilePath Source #
Create a FilePath
from a ModuleIdent
using the hierarchical module
system
fileNameToModule :: FilePath -> ModuleIdent Source #
Extract the ModuleIdent
from a FilePath
splitModuleFileName :: ModuleIdent -> FilePath -> (FilePath, FilePath) Source #
Split a FilePath
into a prefix directory part and those part that
corresponds to the ModuleIdent
. This is especially useful for
hierarchically module names.
isCurryFilePath :: String -> Bool Source #
Curry sub-directory
currySubdir :: String Source #
The standard hidden subdirectory for curry files
hasCurrySubdir :: FilePath -> Bool Source #
Does the given FilePath
contain the currySubdir
as its last directory component?
addCurrySubdir :: Bool -> FilePath -> FilePath Source #
Add the currySubdir
to the given FilePath
if the flag is True
and
the path does not already contain it, otherwise leave the path untouched.
addCurrySubdirModule :: Bool -> ModuleIdent -> FilePath -> FilePath Source #
Add the currySubdir
to the given FilePath
if the flag is True
and
the path does not already contain it, otherwise leave the path untouched.
Ensure that the currySubdir
is the last component of the
directory structure of the given FilePath
. If the FilePath
already
contains the sub-directory, it remains unchanged.
File name extensions
Curry files
FlatCurry files
typedFlatExt :: String Source #
Filename extension for typed flat-curry files
flatIntExt :: String Source #
Filename extension for extended-flat-curry interface files
AbstractCurry files
Source and object files
sourceRepExt :: String Source #
Filename extension for curry source representation files
sourceExts :: [String] Source #
Filename extension for curry source files.
Note: The order of the extensions defines the order in which source files
should be searched for, i.e. given a module name M
, the search order
should be the following:
M.curry
M.lcurry
moduleExts :: [String] Source #
Filename extension for curry module files TODO: Is the order correct?
Functions for computing file names
interfName :: FilePath -> FilePath Source #
Compute the filename of the interface file for a source file
typedFlatName :: FilePath -> FilePath Source #
Compute the filename of the typed flat curry file for a source file
typeAnnFlatName :: FilePath -> FilePath Source #
Compute the filename of the typed flat curry file for a source file
flatName :: FilePath -> FilePath Source #
Compute the filename of the flat curry file for a source file
flatIntName :: FilePath -> FilePath Source #
Compute the filename of the flat curry interface file for a source file
acyName :: FilePath -> FilePath Source #
Compute the filename of the abstract curry file for a source file
uacyName :: FilePath -> FilePath Source #
Compute the filename of the untyped abstract curry file for a source file
sourceRepName :: FilePath -> FilePath Source #
Compute the filename of the source representation file for a source file
tokensName :: FilePath -> FilePath Source #
Compute the filename of the tokens file for a source file
commentsName :: FilePath -> FilePath Source #
Compute the filename of the comment tokens file for a source file
shortASTName :: FilePath -> FilePath Source #
Compute the filename of the ast file for a source file
htmlName :: ModuleIdent -> String Source #
Compute the filename of the HTML file for a source file