Implement floating point conversion with ryu by 0xlwu · Pull Request #222 · haskell/bytestring (original) (raw)
I am no expert in this area, unfortunately.
There are several attack vectors:
- I would probably start with raising questions about
show :: Double -> Stringinbase. It is worth exploring whether folks are happy to change it (including round-to-even step or whatever is desirable) or no. - Submit as a separate PR comprehensive tests. Whatever happens next, such tests will be helpful for this and any future implementations of float-to-string.
- Another option is to make a companion package
bytestring-ryuto provide fastfloatDec :: Float -> BuilderanddoubleDec :: Double -> Builder. Are there enough internals exposed? Being a separate package allows to put a big red warning that this is not exactly the same conversion asshowdoes.
I don't want to discourage you from contributing to bytestring. But as you might guess from #115, submitting a huge chunk of code makes maintainers nervous and takes ages to review and merge. That's because the price of a mistake is extremely high, and it is difficult to roll out a hot fix of the package, tied to GHC.
This is why I would go with bytestring-ryu, promote it, propose other packages to use it, gather feedback, make couple of iterations. (I'm happy to help at any stage, if needed.) This will give a much better ground to adopt it as a standard algorithm in bytestring later.