Module System.CurryPath

This module contains operations related to module names and paths used in Curry system.

Author: Bernd Brassel, Michael Hanus, Bjoern Peemoeller, Finn Teegen

Version: March 2024

Summary of exported operations:

splitProgramName :: String -> (String,String)  Deterministic 
Splits a program name, i.e., a module name possibly prefixed by a directory, into the directory and the module name.
splitValidProgramName :: String -> (String,String)  Deterministic 
Splits a program name, i.e., a module name possibly prefixed by a directory, into the directory and a valid module name.
isValidModuleName :: String -> Bool  Deterministic 
Is the given string a valid module name?
runModuleAction :: (String -> IO a) -> String -> IO a  Deterministic 
Executes an I/O action, which is parameterized over a module name, for a given program name.
runModuleActionQuiet :: (String -> IO a) -> String -> IO a  Deterministic 
Executes an I/O action, which is parameterized over a module name, for a given program name.
splitModuleFileName :: String -> String -> (String,String)  Deterministic 
Split the FilePath of a module into the directory prefix and the FilePath corresponding to the module name.
splitModuleIdentifiers :: String -> [String]  Deterministic 
Split up the components of a module identifier.
joinModuleIdentifiers :: [String] -> String  Deterministic 
Join the components of a module identifier.
stripCurrySuffix :: String -> String  Deterministic 
Strips the suffix .curry or .lcurry from a file name.
modNameToPath :: String -> String  Deterministic 
Transforms a hierarchical module name into a path name, i.e., replace the dots in the name by directory separator chars.
currySubdir :: String  Deterministic 
Name of the sub directory where auxiliary files (.fint, .fcy, etc) are stored.
inCurrySubdir :: String -> String  Deterministic 
Transforms a path to a module name into a file name by adding the result of currySubDir to the path and transforming a hierarchical module name into a path.
inCurrySubdirModule :: String -> String -> String  Deterministic 
Transforms a file name by adding the currySubDir to the file name.
addCurrySubdir :: String -> String  Deterministic 
Transforms a directory name into the name of the corresponding sub directory containing auxiliary files.
sysLibPath :: [String]  Deterministic 
Finding files in correspondence to compiler load path Returns the current path (list of directory names) of the system libraries.
getLoadPathForModule :: String -> IO [String]  Deterministic 
Returns the current path (list of directory names) that is used for loading modules w.r.t.
lookupModuleSourceInLoadPath :: String -> IO (Maybe (String,String))  Deterministic 
Returns a directory name and the actual source file name for a given module name (where a possible curry suffix is stripped off) by looking up the module source in the current load path.
lookupModuleSource :: [String] -> String -> IO (Maybe (String,String))  Deterministic 
Returns a directory name and the actual source file name for a given module name (where a possible curry suffix is stripped off) by looking up the module source in the load path provided as the first argument.
curryModulesInDirectory :: String -> IO [String]  Deterministic 
Gets the names of all Curry modules contained in a given directory.
curryrcFileName :: IO String  Deterministic 
The name of the file specifying resource configuration parameters of the current distribution.
setCurryPath :: Bool -> String -> IO ()  Deterministic 
If the environment variable CURRYPATH is not already set (i.e., not null), set it to the value computed by cypm deps --path in order to allow invoking tools without cypm exec ....

Exported datatypes:


ModuleIdent

Functions for handling file names of Curry modules

Type synonym: ModuleIdent = String


ModulePath

A module path consists of a directory prefix (which can be omitted) and a module name (which can be hierarchical). For instance, the following strings are module paths in Unix-based systems:

HTML
Data.Number.Int
curry/Data.Number.Int

Type synonym: ModulePath = String


Exported operations:

splitProgramName :: String -> (String,String)  Deterministic 

Splits a program name, i.e., a module name possibly prefixed by a directory, into the directory and the module name. A possible suffix like .curry or .lcurry is dropped from the module name. For instance splitProgramName "lib/Data.Set.curry" evaluates to ("lib","Data.Set").

splitValidProgramName :: String -> (String,String)  Deterministic 

Splits a program name, i.e., a module name possibly prefixed by a directory, into the directory and a valid module name. A possible suffix like .curry or .lcurry is dropped from the module name. For instance splitValidProgramName "lib/Data.Set.curry" evaluates to ("lib","Data.Set"). An error is raised if the program name is empty or the module name is not valid.

isValidModuleName :: String -> Bool  Deterministic 

Is the given string a valid module name?

runModuleAction :: (String -> IO a) -> String -> IO a  Deterministic 

Executes an I/O action, which is parameterized over a module name, for a given program name. If the program name is prefixed by a directory, switch to this directory before executing the action, report this switch on stdout, and switch back after the action. A possible suffix like .curry or .lcurry is dropped from the module name passed to the action. An error is raised if the module name is not valid.

runModuleActionQuiet :: (String -> IO a) -> String -> IO a  Deterministic 

Executes an I/O action, which is parameterized over a module name, for a given program name. If the program name is prefixed by a directory, switch to this directory before executing the action and switch back after the action. A possible suffix like .curry or .lcurry is dropped from the module name passed to the action. An error is raised if the module name is not valid.

splitModuleFileName :: String -> String -> (String,String)  Deterministic 

Split the FilePath of a module into the directory prefix and the FilePath corresponding to the module name. For instance, the call splitModuleFileName "Data.Set" "lib/Data/Set.curry" evaluates to ("lib", "Data/Set.curry"). This can be useful to compute output directories while retaining the hierarchical module structure.

splitModuleIdentifiers :: String -> [String]  Deterministic 

Split up the components of a module identifier. For instance, splitModuleIdentifiers "Data.Set" evaluates to ["Data", "Set"].

joinModuleIdentifiers :: [String] -> String  Deterministic 

Join the components of a module identifier. For instance, joinModuleIdentifiers ["Data", "Set"] evaluates to "Data.Set".

stripCurrySuffix :: String -> String  Deterministic 

Strips the suffix .curry or .lcurry from a file name.

modNameToPath :: String -> String  Deterministic 

Transforms a hierarchical module name into a path name, i.e., replace the dots in the name by directory separator chars.

currySubdir :: String  Deterministic 

Name of the sub directory where auxiliary files (.fint, .fcy, etc) are stored. Note that the name of this directory depends on the compiler to avoid confusion when using different compilers. For instance, when using PAKCS 3.2.0, currySubdir evaluates to ".curry/pakcs-3.2.0".

inCurrySubdir :: String -> String  Deterministic 

Transforms a path to a module name into a file name by adding the result of currySubDir to the path and transforming a hierarchical module name into a path. For instance, when using PAKCS 3.2.0, inCurrySubdir "mylib/Data.Char" evaluates to "mylib/.curry/pakcs-3.2.0/Data/Char".

inCurrySubdirModule :: String -> String -> String  Deterministic 

Transforms a file name by adding the currySubDir to the file name. This version respects hierarchical module names.

addCurrySubdir :: String -> String  Deterministic 

Transforms a directory name into the name of the corresponding sub directory containing auxiliary files.

sysLibPath :: [String]  Deterministic 

Finding files in correspondence to compiler load path Returns the current path (list of directory names) of the system libraries.

getLoadPathForModule :: String -> IO [String]  Deterministic 

Returns the current path (list of directory names) that is used for loading modules w.r.t. a given module path. The directory prefix of the module path (or "." if there is no such prefix) is the first element of the load path and the remaining elements are determined by the environment variable CURRYRPATH and the entry "libraries" of the system's rc file.

lookupModuleSourceInLoadPath :: String -> IO (Maybe (String,String))  Deterministic 

Returns a directory name and the actual source file name for a given module name (where a possible curry suffix is stripped off) by looking up the module source in the current load path. If the module is hierarchical, the directory is the top directory of the hierarchy. Returns Nothing if there is no corresponding source file.

lookupModuleSource :: [String] -> String -> IO (Maybe (String,String))  Deterministic 

Returns a directory name and the actual source file name for a given module name (where a possible curry suffix is stripped off) by looking up the module source in the load path provided as the first argument. If the module is hierarchical, the directory is the top directory of the hierarchy. Returns Nothing if there is no corresponding source file.

curryModulesInDirectory :: String -> IO [String]  Deterministic 

Gets the names of all Curry modules contained in a given directory. Modules in subdirectories are returned as hierarchical module names.

curryrcFileName :: IO String  Deterministic 

The name of the file specifying resource configuration parameters of the current distribution. This file must have the usual format of property files.

setCurryPath :: Bool -> String -> IO ()  Deterministic 

If the environment variable CURRYPATH is not already set (i.e., not null), set it to the value computed by cypm deps --path in order to allow invoking tools without cypm exec .... If the first argument is False, the computed path value is printed. If the second argument is not null, its value is taken as the executable for CPM, otherwise the executable cypm is searched in the current path (environment variable PATH).