Module FlatCurry.Files

This library defines I/O actions to read Curry programs and transform them into the FlatCurry representation.

Author: Michael Hanus, Finn Teegen

Version: November 2023

Summary of exported operations:

readFlatCurry :: String -> IO Prog  Non-deterministic 
I/O action which parses a Curry module and returns the corresponding FlatCurry program.
readFlatCurryWithParseOptions :: String -> FrontendParams -> IO Prog  Non-deterministic 
I/O action which parses a Curry module with respect to some parser options and returns the corresponding FlatCurry program.
flatCurryFileName :: String -> String  Deterministic 
Transforms a name of a Curry module (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding FlatCurry program.
flatCurryIntName :: String -> String  Deterministic 
Transforms a name of a Curry module (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding FlatCurry program.
readFlatCurryFile :: String -> IO Prog  Non-deterministic 
I/O action which reads a FlatCurry program from a file in .fcy format.
readFlatCurryInt :: String -> IO Prog  Non-deterministic 
I/O action which returns the interface of a Curry module, i.e., a FlatCurry program containing only "Public" entities and function definitions without rules (i.e., external functions).
readFlatCurryIntWithParseOptions :: String -> FrontendParams -> IO Prog  Non-deterministic 
I/O action which parses a Curry module with respect to some parser options and returns the FlatCurry interface of this program, i.e., a FlatCurry program containing only "Public" entities and function definitions without rules (i.e., external functions).
writeFlatCurry :: Prog -> IO ()  Non-deterministic 
Writes a FlatCurry program into a file in .fcy format.
writeFlatCurryFile :: String -> Prog -> IO ()  Non-deterministic 
Writes a FlatCurry program into a file in .fcy format.
writeFCY :: String -> Prog -> IO ()  Non-deterministic 
Writes a FlatCurry program into a file in .fcy format.
lookupFlatCurryFileInLoadPath :: String -> IO (Maybe String)  Deterministic 
Returns the name of the FlatCurry file of a module in the load path, if this file exists.
getFlatCurryFileInLoadPath :: String -> IO String  Deterministic 
Returns the name of the FlatCurry file of a module in the load path, if this file exists.

Exported operations:

readFlatCurry :: String -> IO Prog  Non-deterministic 

I/O action which parses a Curry module and returns the corresponding FlatCurry program. The argument is the module name (without suffix ".curry" or ".lcurry") and the result is a FlatCurry term representing this module.

If one wants to parse a Curry module in another directory, e.g., the file examples/Mod.curry, one can use the operation runModuleAction from module System.CurryPath of package currypath to transform this I/O action so that it switches into the directory before reading:

> runModuleAction readFlatCurry examples/Mod.curry

readFlatCurryWithParseOptions :: String -> FrontendParams -> IO Prog  Non-deterministic 

I/O action which parses a Curry module with respect to some parser options and returns the corresponding FlatCurry program. The argument is the module name (without suffix ".curry" or ".lcurry") and the result is a FlatCurry term representing this module.

Example call:
(readFlatCurryWithParseOptions modname options)
Parameters:
  • modname : the module name (without suffix ".curry")
  • options : parameters passed to the front end

flatCurryFileName :: String -> String  Deterministic 

Transforms a name of a Curry module (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding FlatCurry program.

flatCurryIntName :: String -> String  Deterministic 

Transforms a name of a Curry module (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding FlatCurry program.

readFlatCurryFile :: String -> IO Prog  Non-deterministic 

I/O action which reads a FlatCurry program from a file in .fcy format. In contrast to readFlatCurry, this action does not parse a source program. Thus, the argument must be the name of an existing file (with suffix .fcy) containing a FlatCurry program in .fcy format and the result is a FlatCurry term representing this program.

readFlatCurryInt :: String -> IO Prog  Non-deterministic 

I/O action which returns the interface of a Curry module, i.e., a FlatCurry program containing only "Public" entities and function definitions without rules (i.e., external functions). The argument is the module name (without suffix ".curry" or ".lcurry") and the result is a FlatCurry term representing the interface of this module.

If one wants to parse a Curry module in another directory, e.g., the file examples/Mod.curry, one can use the operation runModuleAction from module System.CurryPath of package currypath to transform this I/O action so that it switches into the directory before reading:

> runModuleAction readFlatCurryInt "examples/Mod.curry"

readFlatCurryIntWithParseOptions :: String -> FrontendParams -> IO Prog  Non-deterministic 

I/O action which parses a Curry module with respect to some parser options and returns the FlatCurry interface of this program, i.e., a FlatCurry program containing only "Public" entities and function definitions without rules (i.e., external functions). The argument is the module name without suffix ".curry" (or ".lcurry") and the result is a FlatCurry term representing the interface of this module.

writeFlatCurry :: Prog -> IO ()  Non-deterministic 

Writes a FlatCurry program into a file in .fcy format. The file is written in the standard location for intermediate files, i.e., in the flatCurryFileName relative to the directory of the Curry source program (which must exist!).

writeFlatCurryFile :: String -> Prog -> IO ()  Non-deterministic 

Writes a FlatCurry program into a file in .fcy format. The first argument must be the name of the target file (usually with suffix .fcy).

writeFCY :: String -> Prog -> IO ()  Non-deterministic 

Writes a FlatCurry program into a file in .fcy format. The first argument must be the name of the target file (usually with suffix .fcy).

lookupFlatCurryFileInLoadPath :: String -> IO (Maybe String)  Deterministic 

Returns the name of the FlatCurry file of a module in the load path, if this file exists.

getFlatCurryFileInLoadPath :: String -> IO String  Deterministic 

Returns the name of the FlatCurry file of a module in the load path, if this file exists.