Module AbstractCurry.Files

This library defines various I/O actions to read Curry programs and transform them into the AbstractCurry representation and to write AbstractCurry files.

Assumption: an abstract Curry program is stored in file with extension .acy in the subdirectory .curry

Author: Michael Hanus, Bjoern Peemoeller, Jan Tikovsky, Finn Teegen

Version: December 2024

Summary of exported operations:

readCurry :: String -> IO CurryProg  Non-deterministic 
I/O action which parses a Curry program and returns the corresponding typed Abstract Curry program.
readCurryWithImports :: String -> IO [CurryProg]  Non-deterministic 
Read an AbstractCurry file with all its imports.
tryReadCurryWithImports :: String -> IO (Either [String] [CurryProg])  Non-deterministic 
tryReadCurryFile :: String -> IO (Either String CurryProg)  Non-deterministic 
tryParse :: String -> IO (Either String CurryProg)  Non-deterministic 
Try to parse an AbstractCurry file.
readUntypedCurry :: String -> IO CurryProg  Non-deterministic 
I/O action which parses a Curry program and returns the corresponding untyped AbstractCurry program.
readCurryWithParseOptions :: String -> FrontendParams -> IO CurryProg  Non-deterministic 
I/O action which reads a typed Curry program from a file (with extension ".acy") with respect to some parser options.
readUntypedCurryWithParseOptions :: String -> FrontendParams -> IO CurryProg  Non-deterministic 
I/O action which reads an untyped Curry program from a file (with extension ".uacy") with respect to some parser options.
abstractCurryFileName :: String -> String  Deterministic 
Transforms a name of a Curry program (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding AbstractCurry program.
untypedAbstractCurryFileName :: String -> String  Deterministic 
Transforms a name of a Curry program (with or without suffix ".curry" or ".lcurry") into the name of the file containing the corresponding untyped AbstractCurry program.
readAbstractCurryFile :: String -> IO CurryProg  Non-deterministic 
I/O action which reads an AbstractCurry program from a file in ".acy" format.
tryReadACYFile :: String -> IO (Maybe CurryProg)  Non-deterministic 

Tries to read an AbstractCurry file and returns

  • Left err , where err specifies the error occurred
  • Right prog, where prog is the AbstractCurry program
readACYString :: String -> Maybe CurryProg  Non-deterministic 
writeAbstractCurryFile :: String -> CurryProg -> IO ()  Non-deterministic 
Writes an AbstractCurry program into a file in ".acy" format.

Exported operations:

readCurry :: String -> IO CurryProg  Non-deterministic 

I/O action which parses a Curry program and returns the corresponding typed Abstract Curry program. Thus, the argument is the file name without suffix ".curry" or ".lcurry") and the result is a Curry term representing this program.

readCurryWithImports :: String -> IO [CurryProg]  Non-deterministic 

Read an AbstractCurry file with all its imports.

Example call:
(readCurryWithImports modname)
Parameters:
  • modname : Module name or file name of Curry module
Returns:
a list of curry programs, having the AbstractCurry file as head.

tryReadCurryWithImports :: String -> IO (Either [String] [CurryProg])  Non-deterministic 

tryReadCurryFile :: String -> IO (Either String CurryProg)  Non-deterministic 

tryParse :: String -> IO (Either String CurryProg)  Non-deterministic 

Try to parse an AbstractCurry file.

Example call:
(tryParse fn)
Parameters:
  • fn : file name of AbstractCurry file

readUntypedCurry :: String -> IO CurryProg  Non-deterministic 

I/O action which parses a Curry program and returns the corresponding untyped AbstractCurry program. The argument is the file name without suffix ".curry" or ".lcurry") and the result is a Curry term representing this program. In an untyped AbstractCurry program, the type signatures of operations are the type signatures provided by the programmer (and not the type signatures inferred by the front end). If the programmer has not provided an explicit type signature, the function declaration contains the type (CTCons ("Prelude","untyped").

readCurryWithParseOptions :: String -> FrontendParams -> IO CurryProg  Non-deterministic 

I/O action which reads a typed Curry program from a file (with extension ".acy") with respect to some parser options. This I/O action is used by the standard action readCurry. It is currently predefined only in Curry2Prolog.

Example call:
(readCurryWithParseOptions progfile options)
Parameters:
  • progfile : the program file name (without suffix ".curry")
  • options : parameters passed to the front end

readUntypedCurryWithParseOptions :: String -> FrontendParams -> IO CurryProg  Non-deterministic 

I/O action which reads an untyped Curry program from a file (with extension ".uacy") with respect to some parser options. For more details see function readCurryWithParseOptions In an untyped AbstractCurry program, the type signatures of operations are the type signatures provided by the programmer (and not the type signatures inferred by the front end). If the programmer has not provided an explicit type signature, the function declaration contains the type (CTCons ("Prelude","untyped").

abstractCurryFileName :: String -> String  Deterministic 

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

untypedAbstractCurryFileName :: String -> String  Deterministic 

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

readAbstractCurryFile :: String -> IO CurryProg  Non-deterministic 

I/O action which reads an AbstractCurry program from a file in ".acy" format. In contrast to CODEreadCurry/CODE, this action does not parse a source program. Thus, the argument must be the name of an existing file (with suffix ".acy") containing an AbstractCurry program in ".acy" format and the result is a Curry term representing this program. It is currently predefined only in Curry2Prolog.

tryReadACYFile :: String -> IO (Maybe CurryProg)  Non-deterministic 

Tries to read an AbstractCurry file and returns

  • Left err , where err specifies the error occurred
  • Right prog, where prog is the AbstractCurry program

readACYString :: String -> Maybe CurryProg  Non-deterministic 

writeAbstractCurryFile :: String -> CurryProg -> IO ()  Non-deterministic 

Writes an AbstractCurry program into a file in ".acy" format. The first argument must be the name of the target file (with suffix ".acy").