[Haskell-cafe] [ANN] FloatingHex: Hexadecimal floats (quasiquoter and pretty-printer)
erkokl at gmail.com
Tue Jan 17 23:29:56 UTC 2017
Thanks Iavor.. I should've indeed done that, but instead I directly opened
a GHC feature request: http://ghc.haskell.org/trac/ghc/ticket/13126. Old
habits die hard.
I've since turned it into a proper proposal:
However, I was *not* able to add the label "Under discussion" as suggested
by the instructions in:
I didn't see a way of doing that in the pull-request. Perhaps a guru can
On Tue, Jan 17, 2017 at 11:38 AM, Iavor Diatchki <iavor.diatchki at gmail.com>
> Nicely done! I agree that this would be much nicer to just implement
> directly in GHC (and eventually add to the standard). Would you like to
> write it up as GHC proposal?
> Here is info on how to do that:
> On Sat, Jan 14, 2017 at 3:06 PM, Levent Erkok <erkokl at gmail.com> wrote:
>> Quick update: version 0.2 of FloatingHex is now on hackage (
>> http://hackage.haskell.org/package/FloatingHex) which fixes a few
>> glitches and makes the pretty-printer compatible with C's %a modifier. This
>> brings the support on par with that in C/C++. The quasi-quoter is called
>> qf, and the pretty-printer is called showHFloat, following the naming of
>> other float-printers already available.
>> On Sat, Jan 14, 2017 at 1:10 AM, Levent Erkok <erkokl at gmail.com> wrote:
>>> FloatingHex (http://hackage.haskell.org/package/FloatingHex) is a
>>> simple package that implement hexadecimal notation for floating point
>>> numbers, as described in p57-58 of http://www.open-std.org/jtc
>>> The package provides a quasi-quoter for hexadecimal floats: hf, and a
>>> pretty-printer for floats to show them in this notation: showFFloat. (Note
>>> that the latter is not 100% compatible with C's %a modifier for printf, but
>>> it does render a faithful representation of its input.)
>>> Hex-floats are useful as they allow writing floating-point constants
>>> without any loss of precision, while remaining human readable. For
>>> instance, the float 2 is written as 0x1p1. (With the quasiquoter, the
>>> syntax is [hf|0x1p1|].) This representation is to be preferred over decimal
>>> rendering where loss of precision can be a problem: Note that not all
>>> floating point numbers have a terminating decimal representation as
>>> currently required by the Haskell syntax.
>>> It would be nice if Haskell itself allowed for such literals in the
>>> language specs itself, following the recent changes to other language
>>> standards. (Again, see p57-58 of http://www.open-std.org/jtc
>>> 1/sc22/wg14/www/docs/n1256.pdf for the new C standard.) In the mean
>>> time, I hope FloatingHex library will provide a workaround for
>>> the numerophilias amongst us.
>>> Bug reports and improvements always welcome!
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe