So my question is: why (in this second example) Integer is inferred? What makes a difference?
I think there are two things going on. First, the monomorphism restriction is causing the types to be different. I'm not sure why Integer -> Integer is the default choice, though. I tend to write the type signatures I want before I write the implementation, so I don't run into these kinds of issues often.