我有以下程序:
data Peano = Zero | Succ Peano deriving (Show)
add Zero b = b
add (Succ a) b = add a (Succ b)
mul Zero b = Zero
mul (Succ a) b = add b (mul a b)
four x = let two = Succ (Succ Zero) in mul two two
我想从GHC得到这样的:
add =
\ ds b ->
case ds of
Zero ->
b
Succ a ->
add
a
(Succ b)
mul =
\ ds b ->
case ds of
Zero ->
Zero
Succ a ->
add
b
(mul a b)
four =
let
two =
Succ
(Succ Zero)
in
mul two two
我设法得到最好的是
ghci -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques foo.hs
但钢需要大量的手工清除GHC的生成的东西拿到上面的代码。 是否有GHC或第三方脚本,并清除开关?
有没有一种办法,至少摆脱case {tick (main:Main, 8)} @ (State# RealWorld) of _ { __DEFAULT ->
?