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 2018

Summary of exported operations:

readCurry :: String -> IO CurryProg   
I/O action which parses a Curry program and returns the corresponding typed Abstract Curry program.
readCurryWithImports :: String -> IO [CurryProg]   
Read an AbstractCurry file with all its imports.
tryReadCurryWithImports :: String -> IO (Either [String] [CurryProg])   
tryReadCurryFile :: String -> IO (Either String CurryProg)   
tryParse :: String -> IO (Either String CurryProg)   
Try to parse an AbstractCurry file.
readUntypedCurry :: String -> IO CurryProg   
I/O action which parses a Curry program and returns the corresponding untyped AbstractCurry program.
readCurryWithParseOptions :: String -> FrontendParams -> IO CurryProg   
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   
I/O action which reads an untyped Curry program from a file (with extension ".uacy") with respect to some parser options.
abstractCurryFileName :: String -> String   
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   
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   
I/O action which reads an AbstractCurry program from a file in ".acy" format.
tryReadACYFile :: String -> IO (Maybe CurryProg)   

Tries to read an AbstractCurry file and returns

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

Exported operations:

readCurry :: String -> IO CurryProg   

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]   

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])   

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

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

Try to parse an AbstractCurry file.

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

readUntypedCurry :: String -> IO CurryProg   

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   

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   

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   

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   

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   

I/O action which reads an AbstractCurry program from a file in ".acy" format. In contrast to readCurry, 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)   

Tries to read an AbstractCurry file and returns

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

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

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