У меня есть следующая программа:
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
Лучшее, что мне удалось get это
ghci -ddump-simpl -dsuppress-module-prefixes -dsuppress-uniques foo.hs
, но для получения приведенного выше кода потребовалось много ручного удаления сгенерированного GHC материала. Есть ли переключатель для GHC или сторонний скрипт, который выполняет очистку?
Есть ли способ хотя бы избавиться от case {tick (main:Main, 8)} @ (State# RealWorld) of _ { __DEFAULT ->
?