CurryInfo: currypp-3.2.0 / Main.pathToModName

definition: Info
 
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: Info
 no demanded arguments
deterministic: Info
 deterministic operation
documentation: Info
 
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: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,_) |-> {(,)}}
name: Info
 pathToModName
precedence: Info
 no precedence defined
result-values: Info
 {(,)}
signature: Info
 String -> String -> (Prelude.Maybe String, String)
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term