curry-base-1.1.1: Functions for manipulating Curry programs

Copyright(c) 2009 Holger Siegel
2013 - 2014 Björn Peemöller
2018 Kai-Oliver Prott
LicenseBSD-3-clause
Maintainerfte@informatik.uni-kiel.de
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Curry.Files.Filenames

Contents

Description

The functions in this module were collected from several compiler modules in order to provide a unique accessing point for this functionality.

Synopsis

Re-exports from FilePath

type FilePath = String #

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

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 #

Checks whether a String represents a FilePath to a Curry module

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.

ensureCurrySubdir Source #

Arguments

:: FilePath

original FilePath

-> FilePath

new FilePath

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

curryExt :: String Source #

Filename extension for non-literate curry files

lcurryExt :: String Source #

Filename extension for literate curry files

icurryExt :: String Source #

Filename extension for curry interface files

FlatCurry files

typedFlatExt :: String Source #

Filename extension for typed flat-curry files

flatExt :: String Source #

Filename extension for flat-curry files

flatIntExt :: String Source #

Filename extension for extended-flat-curry interface files

AbstractCurry files

acyExt :: String Source #

Filename extension for abstract-curry files

uacyExt :: String Source #

Filename extension for untyped-abstract-curry 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:

  1. M.curry
  2. 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

astName :: FilePath -> FilePath Source #

Compute the filename of the ast 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