Module ICurry.Files

Module for handling ICurry and related files

Author: Marc Andre Wittorf

Summary of exported operations:

defaultPaths :: [String]   
Default search paths (obtained from CURRYPATH environment variable)
mapJust :: (a -> b) -> Maybe a -> Maybe b   
Basically the Maybe functor instance
normaliser :: Maybe String -> IO (Maybe String)   
Bindable IO action to normalize a file path
lookupToGet :: ([String] -> String -> IO (Maybe String)) -> IO String -> [String] -> String -> IO String   
Make a lookup (returns Maybe) function to a get function (uses error)
lookupCurryFile :: [String] -> String -> IO (Maybe String)   
Look up a Curry file in the search paths
getCurryFile :: [String] -> String -> IO String   
Get a Curry file in the search paths.
lookupFlatFile :: [String] -> String -> IO (Maybe String)   
Look up a Typed FlatCurry file in the search paths
getFlatFile :: [String] -> String -> IO String   
Get a Typed FlatCurry file in the search paths.
lookupTypeDepsFile :: [String] -> String -> IO (Maybe String)   
Look up a Type Dependency file in the search paths
lookupTypeDepsFileRaw :: [String] -> String -> IO (Maybe String)   
Look up a Type Dependency file.
getTypeDepsFile :: [String] -> String -> IO String   
Get a Type Dependency file in the search paths.
getTypeDepsFileRaw :: [String] -> String -> IO String   
Get a Type Dependency file.
lookupICurryFile :: [String] -> String -> IO (Maybe String)   
Look up an ICurry file in the search paths
lookupICurryFileRaw :: [String] -> String -> IO (Maybe String)   
Look up an ICurry file in the search paths.
getICurryFile :: [String] -> String -> IO String   
Get an ICurry file in the search paths.
getICurryFileRaw :: [String] -> String -> IO String   
Get an ICurry file in the search paths.
getPathForModule :: [String] -> String -> IO String   

Get the root directory where a module is located under

Example: a module Foo.Bar that can be found under /dir/subdir/Foo/Bar.curry will cause a return value of /dir/subdir

readFlat :: [String] -> String -> IO (AProg TypeExpr)   
Read a FlatCurry file.
readTypeDeps :: [String] -> String -> IO [((String,String),(TypeExpr,[Int]))]   
Read a Type Dependency file.
readICurry :: [String] -> String -> IO IProg   
Read an ICurry file.
readICurryRaw :: [String] -> String -> IO IProg   
Read an ICurry file.
writeTypeDeps :: [String] -> String -> [((String,String),(TypeExpr,[Int]))] -> IO ()   
Write a Type Dependency file.
writeICurry :: [String] -> String -> IProg -> IO ()   
Write an ICurry file.
icurryFrontendTarget :: FrontendTarget   
The correct target for frontend invocation to translate to Typed FlatCurry
moduleRoot :: String -> String -> String   
Get the module root path from a module path and its name
workaround :: a -> a -> a   
Dispatch something based on if a compiler version is buggy

Exported operations:

defaultPaths :: [String]   

Default search paths (obtained from CURRYPATH environment variable)

mapJust :: (a -> b) -> Maybe a -> Maybe b   

Basically the Maybe functor instance

Example call:
(mapJust f v)
Parameters:
  • f : the function to transform a Just constructor's content
  • v : the value
Returns:
the transformed value

normaliser :: Maybe String -> IO (Maybe String)   

Bindable IO action to normalize a file path

Example call:
(normaliser fp)
Parameters:
  • fp : the file path
Returns:
the normalized file path (if applicable)

lookupToGet :: ([String] -> String -> IO (Maybe String)) -> IO String -> [String] -> String -> IO String   

Make a lookup (returns Maybe) function to a get function (uses error)

Example call:
(lookupToGet lookupper err paths modname)
Parameters:
  • lookupper : the lookup function
  • err : the fallback function if nothing is found
  • paths : the lookup paths
  • modname : the module name to search
Returns:
the lookup function's result (or err if not found)

lookupCurryFile :: [String] -> String -> IO (Maybe String)   

Look up a Curry file in the search paths

Example call:
(lookupCurryFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the module's path

getCurryFile :: [String] -> String -> IO String   

Get a Curry file in the search paths. Error if not found

Example call:
(getCurryFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the module's path

lookupFlatFile :: [String] -> String -> IO (Maybe String)   

Look up a Typed FlatCurry file in the search paths

Example call:
(lookupFlatFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the FlatCurry module's path

getFlatFile :: [String] -> String -> IO String   

Get a Typed FlatCurry file in the search paths. Error if not found

Example call:
(getFlatFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the FlatCurry module's path

lookupTypeDepsFile :: [String] -> String -> IO (Maybe String)   

Look up a Type Dependency file in the search paths

Example call:
(lookupTypeDepsFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the Type Dependecy file's path

lookupTypeDepsFileRaw :: [String] -> String -> IO (Maybe String)   

Look up a Type Dependency file. Don't append the .curry subdirectory

Example call:
(lookupTypeDepsFileRaw paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the Type Dependecy file's path

getTypeDepsFile :: [String] -> String -> IO String   

Get a Type Dependency file in the search paths. Error if not found

Example call:
(getTypeDepsFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the Type Dependecy file's path

getTypeDepsFileRaw :: [String] -> String -> IO String   

Get a Type Dependency file. Don't append the .curry subdirectory. Error if not found

Example call:
(getTypeDepsFileRaw paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the Type Dependecy file's path

lookupICurryFile :: [String] -> String -> IO (Maybe String)   

Look up an ICurry file in the search paths

Example call:
(lookupICurryFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry module's path

lookupICurryFileRaw :: [String] -> String -> IO (Maybe String)   

Look up an ICurry file in the search paths. Don't append .curry subdirectory

Example call:
(lookupICurryFileRaw paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry module's path

getICurryFile :: [String] -> String -> IO String   

Get an ICurry file in the search paths. Error if not found

Example call:
(getICurryFile paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry module's path

getICurryFileRaw :: [String] -> String -> IO String   

Get an ICurry file in the search paths. Don't append .curry subdirectory. Error if not found

Example call:
(getICurryFileRaw paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry module's path

getPathForModule :: [String] -> String -> IO String   

Get the root directory where a module is located under

Example: a module Foo.Bar that can be found under /dir/subdir/Foo/Bar.curry will cause a return value of /dir/subdir

Example call:
(getPathForModule paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the source's root directory

readFlat :: [String] -> String -> IO (AProg TypeExpr)   

Read a FlatCurry file. Error if not found

Example call:
(readFlat paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the source file's abstract representation

readTypeDeps :: [String] -> String -> IO [((String,String),(TypeExpr,[Int]))]   

Read a Type Dependency file. Error if not found

Example call:
(readTypeDeps paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the Type Dependencies

readICurry :: [String] -> String -> IO IProg   

Read an ICurry file. Error if not found

Example call:
(readICurry paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry abstract representation

readICurryRaw :: [String] -> String -> IO IProg   

Read an ICurry file. Don't append .curry subdir. Error if not found

Example call:
(readICurryRaw paths modname)
Parameters:
  • paths : the search paths
  • modname : the module name
Returns:
the ICurry abstract representation

writeTypeDeps :: [String] -> String -> [((String,String),(TypeExpr,[Int]))] -> IO ()   

Write a Type Dependency file. Find target directory based on source file

Example call:
(writeTypeDeps paths modname ms)
Parameters:
  • paths : the search paths
  • modname : the module name (for finding correct path)
  • ms : the Type Dependencies

writeICurry :: [String] -> String -> IProg -> IO ()   

Write an ICurry file. Find target directory based on source file

Example call:
(writeICurry paths modname prog)
Parameters:
  • paths : the search paths
  • modname : the module name (for finding correct path)
  • prog : the ICurry module

icurryFrontendTarget :: FrontendTarget   

The correct target for frontend invocation to translate to Typed FlatCurry

moduleRoot :: String -> String -> String   

Get the module root path from a module path and its name

Example call:
(moduleRoot modname path)
Parameters:
  • modname : the module name
  • path : the module's path
Returns:
the root path

workaround :: a -> a -> a   

Dispatch something based on if a compiler version is buggy

Example call:
(workaround yes no)
Parameters:
  • yes : use this if buggy
  • no : use this if not buggy
Returns:
yes or no