Module FlatCurry.Simplify

A simplifier for FlatCurry programs. In particular, it replaces calls to Eq.== implementations by Prelude.==

Author: Michael Hanus

Version: December 2023

Summary of exported operations:

simpProg :: Prog -> Prog  Deterministic 
simpFuncDecl :: FuncDecl -> FuncDecl  Deterministic 
simpExpr :: Expr -> Expr  Deterministic 

Implements the following transformations:

  • simplify equality instance on lists
  • simplify EQ.== calls
  • simplify uses of otherwise: case otherwise of { True -> e1 ; False -> e2 } ==> e1
  • simplify application of Prelude.$: f $ e ==> f e
  • simplify Prelude.apply for partially applied first arguments
  • replace Prelude.otherwise by True
simpClassEq :: Expr -> Expr  Deterministic 
simpArithExp :: Expr -> Expr  Deterministic 
Simplify applications of primitive operations, i.e., apply (apply op e1) e2 ==> op [e1,e2] apply (apply op e1 :: t) e2 ==> op [e1,e2] apply op e1 ==> op [e1]

Exported operations:

simpProg :: Prog -> Prog  Deterministic 

simpExpr :: Expr -> Expr  Deterministic 

Implements the following transformations:

  • simplify equality instance on lists
  • simplify EQ.== calls
  • simplify uses of otherwise: case otherwise of { True -> e1 ; False -> e2 } ==> e1
  • simplify application of Prelude.$: f $ e ==> f e
  • simplify Prelude.apply for partially applied first arguments
  • replace Prelude.otherwise by True

simpClassEq :: Expr -> Expr  Deterministic 

simpArithExp :: Expr -> Expr  Deterministic 

Simplify applications of primitive operations, i.e., apply (apply op e1) e2 ==> op [e1,e2] apply (apply op e1 :: t) e2 ==> op [e1,e2] apply op e1 ==> op [e1]