Desugaring overloaded functions
Bas van Dijk
basvandijk at home.nl
Wed Nov 8 07:57:12 EST 2006
Hello,
I have another question about the desugarer.
When I desugar and apply OccurAnal.occurAnalysePgm on:
incL [] = []
incL (x : xs) = (1 + x) : (incL xs)
I get the beautiful:
Test.incL :: forall a_ad8. (GHC.Num.Num a_ad8) => [a_ad8] -> [a_ad8]
[Exported]
[]
Test.incL =
\ (@ a_akG) ($dNum_akS :: {GHC.Num.Num a_akG}) ->
let {
$dNum_alc [Once Nothing] :: {GHC.Num.Num a_akG}
[]
$dNum_alc = $dNum_akS } in
let {
fromInteger_al9 [Once! Nothing] :: GHC.Num.Integer -> a_akG
[]
fromInteger_al9 = GHC.Num.fromInteger @ a_akG $dNum_alc } in
let {
$dNum_al7 [Once Nothing] :: {GHC.Num.Num a_akG}
[]
$dNum_al7 = $dNum_akS } in
let {
+_akN [OnceL! Nothing] :: a_akG -> a_akG -> a_akG
[]
+_akN = GHC.Num.+ @ a_akG $dNum_al7 } in
let {
lit_akM [OnceL Nothing] :: a_akG
[]
lit_akM = fromInteger_al9 (GHC.Num.S# 1) } in
__letrec {
incL_akO [OnceL! Nothing] :: [a_akG] -> [a_akG]
[]
incL_akO = incL_akH;
incL_akH [LoopBreaker Nothing] :: [a_akG] -> [a_akG]
[]
incL_akH =
\ (ds_dle [Once! Nothing] :: [a_akG]) ->
case ds_dle of wild_B1 [Dead Nothing] {
[] -> GHC.Base.[] @ a_akG;
: x_adb [Once Nothing] xs_adc [Once Nothing] ->
GHC.Base.: @ a_akG (+_akN lit_akM x_adb) (incL_akO xs_adc)
};
} in incL_akH
This is almost exactly what I want. There is one thing I don't understand
though. Namely the __letrec defining:
incL_akO = incL_akH
incL_akH = ... incL_ak0 ...
Why this indirection? Is this also because the desugarer tries to do the most
simple thing? Or is there an other reason?
And is there a preprocess function that translates this into:
incL_akH = ... incL_akH ... ?
regards,
Bas van Dijk
More information about the Glasgow-haskell-users
mailing list