[Haskell-cafe] ANN: The Herbie GHC Plugin

Mike Izbicki mike at izbicki.me
Tue Sep 22 17:17:37 UTC 2015

> My thoughts exactly, I think this would be *really* cool as an HLint-style tool.

The main problem with this is that numerically stable expressions are
often very opaque.  If you look at the first example in the README, I
would definitely rather have:

w far near = -(2 * far * near) / (far - near)

in my code than

w near far = if near < -1.7210442634149447e+81
    then (2.0 * near / (near - far)) * far
    else if near < 8.364504563556443e+16
        then (2.0 * near) / ((near - far) / far)
        else ((2.0 * near) / (near - far)) * far

One of the reasons I use Haskell is because the code is "at the level
of thought" and GHC translates this into awesome speed without the
programmer needing to worry about the gory details in most cases.  I
want that same experience for numerical stability.

More information about the Haskell-Cafe mailing list