Module FlatCurry.Compact

This module contains functions to reduce the size of FlatCurry programs by combining the main module and all imports into a single program that contains only the functions directly or indirectly called from a set of main functions.

Author: Michael Hanus, Carsten Heine

Version: August 2016

Summary of exported operations:

requires :: (String,String) -> (String,String) -> RequiredSpec   
(fun requires reqfun) specifies that the use of the function "fun" implies the application of function "reqfun".
alwaysRequired :: (String,String) -> RequiredSpec   
(alwaysRequired fun) specifies that the function "fun" should be always present if the corresponding module is loaded.
defaultRequired :: [RequiredSpec]   
Functions that are implicitly required in a FlatCurry program (since they might be generated by external functions like "==" or "=:=" on the fly).
generateCompactFlatCurryFile :: [Option] -> String -> String -> IO ()   
Computes a single FlatCurry program containing all functions potentially called from a set of main functions and writes it into a FlatCurry file.
computeCompactFlatCurry :: [Option] -> String -> IO Prog   
Computes a single FlatCurry program containing all functions potentially called from a set of main functions.

Exported datatypes:


Option

Options to guide the compactification process.

Constructors:

  • Verbose :: Option : for more output
  • Main :: String -> Option : optimize for one main (unqualified!) function supplied here
  • Exports :: Option : optimize w.r.t. the exported functions of the module only
  • InitFuncs :: [QName] -> Option : optimize w.r.t. given list of initially required functions
  • Required :: [RequiredSpec] -> Option : list of functions that are implicitly required and, thus, should not be deleted if the corresponding module is imported
  • Import :: String -> Option : module that should always be imported (useful in combination with option InitFuncs)

RequiredSpec

Data type to specify requirements of functions.

Constructors:


Exported operations:

requires :: (String,String) -> (String,String) -> RequiredSpec   

(fun requires reqfun) specifies that the use of the function "fun" implies the application of function "reqfun".

Further infos:
  • defined as non-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

alwaysRequired :: (String,String) -> RequiredSpec   

(alwaysRequired fun) specifies that the function "fun" should be always present if the corresponding module is loaded.

Further infos:
  • solution complete, i.e., able to compute all solutions

defaultRequired :: [RequiredSpec]   

Functions that are implicitly required in a FlatCurry program (since they might be generated by external functions like "==" or "=:=" on the fly).

Further infos:
  • solution complete, i.e., able to compute all solutions

generateCompactFlatCurryFile :: [Option] -> String -> String -> IO ()   

Computes a single FlatCurry program containing all functions potentially called from a set of main functions and writes it into a FlatCurry file. This is done by merging all imported FlatCurry modules and removing the imported functions that are definitely not used.

Example call:
(generateCompactFlatCurryFile options progname target)
Parameters:
  • options : list of options
  • progname : name of the Curry program that should be compacted
  • target : name of the target file where the compact program is saved

computeCompactFlatCurry :: [Option] -> String -> IO Prog   

Computes a single FlatCurry program containing all functions potentially called from a set of main functions. This is done by merging all imported FlatCurry modules (these are loaded demand-driven so that modules that contains no potentially called functions are not loaded) and removing the imported functions that are definitely not used.

Example call:
(computeCompactFlatCurry options progname)
Parameters:
  • options : list of options
  • progname : name of the Curry program that should be compacted
Returns:
the compact FlatCurry program