Why toInteger :: Int -> Integer is lazy?
Posted
by joppux
on Stack Overflow
See other posts from Stack Overflow
or by joppux
Published on 2010-05-01T12:57:43Z
Indexed on
2010/05/01
13:07 UTC
Read the original article
Hit count: 237
I have the following code:
{-# NOINLINE i2i #-}
i2i :: Int -> Integer
i2i x = toInteger x
main = print $ i2i 2
Running GHC with -ddump-simpl flag gives:
[Arity 1
NoCafRefs
Str: DmdType U(L)]
Main.i2i = GHC.Real.toInteger1
Seems that conversion from Int to Integer is lazy. Why is it so - is there a case when I can have
(toInteger _|_ ::Int) /= _|_
?
© Stack Overflow or respective owner