Arity analysis sometimes needs two iterations
Since !4207 (closed), we have seen an increase in "Exciting arity" warnings originating from the arity analyser.
Part of them were due to a bug (#18870 (closed)) that is going to be fixed soon (!4334 (closed)).
But annoyingly, I found (!4334 (comment 308669)) that there are still cases remaining where we emit the warning, for example:
f :: [Int] -> Int -> Int
f [] = id
f (x:xs) = let y = sum [0..x]
in \z -> f xs (y + z)
Fixed-point iteration starts with arity type ⊥
for f
.
After the first iteration, we get arity type \??.T
, e.g. arity 2, because we unconditionally floatIn
the let-binding although it is not cheap. We are allowed to do so, because the arity type of the lambda body is bottoming.
After the second iteration, we get arity type \?.T
, e.g. arity 1, because now we aren't allowed to floatIn
the non-cheap let-binding.
Which is all perfectly benign, but means we do two iterations instead of just one and emit the warning.
I don't see a good way out, other than triggering the warning on the third (and following) iteration only.