It was using sum from the Prelude which is implemented using a non-strict left fold, causing it to blow the stack.