[GHC] #2163: GHC makes thunks for Integers we are strict in
igloo at earth.li
Wed Mar 19 19:49:48 EDT 2008
On Wed, Mar 19, 2008 at 05:31:08PM +0000, Ian Lynagh wrote:
> On Tue, Mar 18, 2008 at 04:12:35PM -0000, GHC wrote:
> > (don't worry, this often catches me out too. Perhaps a strict let
> > should be indicated more explicitly in `-ddump-simpl`).
> I'd certainly find it useful if it was clearer.
In fact, simpl hides more than I'd realised. With these definitions:
f :: Integer -> Integer -> Integer -> Integer
f x y z | y == 1 = x * z
| otherwise = f (x * x) y (z * z)
g :: Integer -> Integer -> Integer -> Integer
g x y z | y == 1 = x
| otherwise = g (x * x) y (z * z)
B.f (GHC.Num.timesInteger x_a5B x_a5B) y_a5D
(GHC.Num.timesInteger z_a5F z_a5F);
B.g (GHC.Num.timesInteger x_a74 x_a74) y_a76
(GHC.Num.timesInteger z_a78 z_a78);
for the recursive calls, although in the STG you can see that the
multiplication of z is done strictly in f but not g (which is correct,
as g is not strict in z).
So perhaps the solution is just that I should look at the STG rather
than the simpl when I want to see what's going on.
More information about the Glasgow-haskell-users