|
definition: |
pathToModName :: String -> String -> (Maybe String, String)
pathToModName currypath psf =
tryRemovePathPrefix (prefixLast (splitSearchPath currypath))
where
pp = stripCurrySuffix psf
tryRemovePathPrefix [] =
let (dir,bname) = splitFileName pp
in (Just (dropTrailingPathSeparator dir), bname)
tryRemovePathPrefix (dir:dirs)
| dir `isPrefixOf` pp = (Nothing, dirPath2mod $ drop (length dir + 1) pp)
| otherwise = tryRemovePathPrefix dirs
-- transform dir-path name into hierarchical module name
dirPath2mod = intercalate "." . splitDirectories
-- move directories which are prefixed by another one in the path
-- before the other ones, e.g.,
-- prefixLast ["src","aaa","src/ab"] == ["src/ab","src","aaa"]
prefixLast [] = []
prefixLast (x:xs) =
let (longer,rest) = partition (x `isPrefixOf`) xs
in if null longer then x : prefixLast xs
else prefixLast (filter (/=x) longer ++ x : rest)
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
documentation: |
Transforms a file path name for a module back into a hierarchical module name since only the file path of a module is passed to the preprocessor. This is done if the file path name is prefixed by a directory in the `currypath`, otherwise the directory of the path is returned in the first result component and the plain base name in the second. This might be wrong for a hierachical module not occurring in the `currypath`, but in this case it is difficult to reconstruct the original module name from the file path without looking inside the module. |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,_) |-> {(,)}}
|
|
name: |
pathToModName |
|
precedence: |
no precedence defined |
|
result-values: |
{(,)}
|
|
signature: |
String -> String -> (Prelude.Maybe String, String) |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |