Module FlatCurry.ElimNewtype

Author
Michael Hanus
Version
March 2021

This module contains operations to eliminate definitions and uses of newtype in a FlatCurry program.

If there is a declaration of the form

newtype NTYPE a1...an = NTCONS te

in a Curry program, the following transformations are preformed:

  • Replace newtype declaration by data declaration.
  • Every type application (NTYPE t1...tn) is replaced by {a1 |-> t1,..., an |-> tn}(te) except for occurrences in instance definitions, i.e., operations named by _inst#....
  • A constructor application (NTCONS e) is replaced by e.
  • A partial constructor application (NTCONS) is replaced by (Prelude.id).
  • A case expresion (f)case x of { NTCONS y -> e} is replaced by {y |-> x}(e).
Exported Functions:

Exported Functions


elimNewtypeInProg :: Prog -> IO Prog  Non-deterministic 

Eliminates all newtype definitions/uses in a FlatCurry program. For this purpose, the interfaces of the imported modules are read before performing the transformation.


elimNewtype :: [Prog] -> Prog -> Prog  Deterministic 

Eliminates all newtype definitions/uses in a FlatCurry program. The first argument are the interfaces of the imported modules.