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 |
Curry.Files.Filenames
Description
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
- defaultOutDir :: String
- hasOutDir :: String -> FilePath -> Bool
- addOutDir :: Bool -> String -> FilePath -> FilePath
- addOutDirModule :: Bool -> String -> ModuleIdent -> FilePath -> FilePath
- ensureOutDir :: String -> FilePath -> FilePath
- curryExt :: String
- lcurryExt :: String
- icurryExt :: String
- annotatedFlatExt :: String
- typedFlatExt :: String
- flatExt :: String
- flatIntExt :: String
- acyExt :: String
- uacyExt :: String
- sourceRepExt :: String
- sourceExts :: [String]
- moduleExts :: [String]
- interfName :: FilePath -> FilePath
- typedFlatName :: FilePath -> FilePath
- annotatedFlatName :: 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
type FilePath = String Source #
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 Source #
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 Source #
Remove last extension, and the "." preceding it.
dropExtension "/directory/path.ext" == "/directory/path" dropExtension x == fst (splitExtension x)
takeExtension :: FilePath -> String Source #
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 Source #
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
defaultOutDir :: String Source #
The standard hidden subdirectory for curry files
hasOutDir :: String -> FilePath -> Bool Source #
Does the given FilePath
contain the outDir
as its last directory component?
addOutDirModule :: Bool -> String -> ModuleIdent -> FilePath -> FilePath Source #
File name extensions
Curry files
FlatCurry files
annotatedFlatExt :: String Source #
Filename extension for type-annotated flat-curry 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
annotatedFlatName :: 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