CurryInfo: verify-non-fail-2.0.0 / FlatCurry.Simplify.simpArithExp

definition:
 
simpArithExp :: Expr -> Expr
simpArithExp exp = case exp of
  Comb FuncCall qt1 [Comb FuncCall qt2 [op, e1], e2]
   | qt1 == pre "apply" && qt2 == qt1
   -- apply (apply op e1) e2 ==> op [e1,e2]
   -> case op of Comb FuncCall qn []           -> replaceBinOp qn e1 e2
                 Typed (Comb FuncCall qn []) _ -> replaceBinOp qn e1 e2
                 _                             -> exp
  Comb FuncCall qt1 [Typed (Comb FuncCall qt2 [op, e1]) _, e2]
   | qt1 == pre "apply" && qt2 == qt1
   -- apply (apply op e1 :: type) e2 ==> op [e1,e2]
   -> case op of Comb FuncCall qn []           -> replaceBinOp qn e1 e2
                 Typed (Comb FuncCall qn []) _ -> replaceBinOp qn e1 e2
                 _                             -> exp
  Comb FuncCall qt1 [op, e1] | qt1 == pre "apply" -- apply op e1 ==> op [e1]
    -> case op of Comb FuncCall qn []           -> replaceUnOp qn e1
                  Typed (Comb FuncCall qn []) _ -> replaceUnOp qn e1
                  _                             -> exp
  Comb FuncCall qn [e1,e2] -> replaceBinOp qn e1 e2
  Comb FuncCall qn [e1]    -> replaceUnOp qn e1
  _                        -> exp
 where
  replaceBinOp (mn,fn) e1 e2
    | mn == "Prelude" = maybe exp
                              (\fp -> Comb FuncCall (mn,fp) [e1,e2])
                              (lookup fn binaryPrimOps)
    | otherwise       = exp

  replaceUnOp (mn,fn) e1
    | mn == "Prelude" = maybe exp
                              (\fp -> Comb FuncCall (mn,fp) [e1])
                              (lookup fn unaryPrimOps)
    | otherwise       = exp
demand:
 argument 1
deterministic:
 deterministic operation
documentation:
 
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]
failfree:
 _
indeterministic:
 referentially transparent operation
infix:
 no fixity defined
iotype:
 {({Comb}) |-> _ || ({Var}) |-> {Var} || ({Lit}) |-> {Lit} || ({Let}) |-> {Let} || ({Free}) |-> {Free} || ({Or}) |-> {Or} || ({Case}) |-> {Case} || ({Typed}) |-> {Typed}}
name:
 simpArithExp
precedence:
 no precedence defined
result-values:
 _
signature:
 FlatCurry.Types.Expr -> FlatCurry.Types.Expr
solution-complete:
 operation might suspend on free variables
terminating:
 possibly non-terminating
totally-defined:
 possibly non-reducible on same data term