I have a function that returns [Int] and I would like to take the sum of the list. However, while each individual element is smaller than maxBound::Int, the sum is definitely larger.
A (contrived) exmple:
ghci> sum ([1..10000000] :: [Int])
-2004260032
Is there any way to force sum to accumulate into an Integer instead of an Int? Am I thinking about this wrong?
sum $ map fromIntegralan appropriate way to do this?