haskell-hvr / HsYAML

YAML 1.2 implementation in pure Haskell
https://hackage.haskell.org/package/HsYAML
GNU General Public License v2.0
55 stars 17 forks source link

Use scientific to fix floating point rounding problems #58

Open mightybyte opened 2 years ago

mightybyte commented 2 years ago

Here's a proof of concept. Do you have a preference about how to resolve the LANGUAGE Safe bit? I was unsure about that.

andreasabel commented 2 years ago

Testsuite fails, missing instances From/ToYaml Double:

[1 of 1] Compiling Main             ( tests/Tests.hs, /__w/HsYAML/HsYAML/dist-newstyle/build/x86_64-linux/ghc-9.2.1/HsYAML-0.2.1.0/t/tests/build/tests/tests-tmp/Main.o )

tests/Tests.hs:26:[32](https://github.com/haskell-hvr/HsYAML/pull/58/checks#step:19:32): error:
    • No instance for (ToYAML Double) arising from a use of ‘outputStr’
    • In the second argument of ‘(==)’, namely ‘outputStr d’
      In the expression: ".nan" == outputStr d

tests/Tests.hs:60:32: error:
    • No instance for (FromYAML Double)
        arising from a use of ‘roundTrip’
    • In the second argument of ‘($)’, namely
        ‘roundTrip approxEq (1 :: Double)’
sjakobi commented 2 years ago

Do you have a preference about how to resolve the LANGUAGE Safe bit?

I don't really have any experience with -XSafe. I'm fine with removing it for now and waiting until someone comes along who cares. :)

andreasabel commented 2 years ago

What is the error if LANGUAGE Safe is left there?