fromIntegral is polymorphic in return type. So you can expect the type y in your code to be Num a => a . This type allows you to use y as the sqrt argument without any problems.
However, due to the restriction of monomorphism, the type y cannot be polymorphic. Therefore, the default is to use the default Num type, which is Integer .
If you execute sqrt $ fromIntegral x monomorphism restriction does not apply, since it applies only to global variables, and you do not save the fromIntegral result in a variable this time.
You can fix this problem by adding a type signature to y ( let y :: Num a => a; y = fromIntegal x ) or by disabling the monomorphism restriction.
sepp2k
source share