Full-precision summation in Haskell I'm trying to speed up the following code for summing doubles with full precision, based on a Python recipe from Raymond Hettinger.  Any thoughts on how to make this go faster?

-- Full precision summation based on http://code.activestate.com/recipes/393090/
msum :: [Double] -&gt; Double
msum [] = 0
msum (x:xs) = sum $ foldl' (\ps x' -&gt; reverse (partials x' ps)) [x] xs

partials :: Double -&gt; [Double] -&gt; [Double]
partials x = foldl' (\acc p -&gt; case hilo x p of (hi, 0) -&gt; hi:acc
                                                (hi, lo) -&gt; hi:lo:acc) []

hilo :: Double -&gt; Double -&gt; (Double, Double)
hilo x y | abs x &lt; abs y = hilo y x
         | otherwise = (hi, lo) where hi = x + y
                                      lo = y - (hi - x)


This is already a second draft; you can see a previous version of the code in this gist.
You could write hilo as hilo :: Double -&gt; Double -&gt; [Double], which returns [hi,lo] for lo /= 0 and [hi] for lo = 0. Then you can write partials as

partials x = foldl' (\acc p -&gt; (hilo x p) ++ acc) -&gt; hi:acc []


BTW: How could lo ever become non-zero considering

lo = y - (hi - x) = y - (x + y - x) = y - y = 0


Rounding?