From f825dd18d904f0e5ca185a849cfd914fd8974008 Mon Sep 17 00:00:00 2001 From: Simon Jakobi Date: Thu, 26 Sep 2019 17:13:43 +0200 Subject: [PATCH] Add link to GHC ticket for rounding issue in Integer/toDouble (#1348) --- dhall/src/Dhall/Core.hs | 4 +++- dhall/src/Dhall/Eval.hs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dhall/src/Dhall/Core.hs b/dhall/src/Dhall/Core.hs index e559662..9f4e3b6 100644 --- a/dhall/src/Dhall/Core.hs +++ b/dhall/src/Dhall/Core.hs @@ -1442,7 +1442,9 @@ normalizeWithM ctx e0 = loop (denote e0) App IntegerShow (IntegerLit n) | 0 <= n -> pure (TextLit (Chunks [] ("+" <> Data.Text.pack (show n)))) | otherwise -> pure (TextLit (Chunks [] (Data.Text.pack (show n)))) - -- `(read . show)` is used instead of `fromInteger` because `read` uses the correct rounding rule + -- `(read . show)` is used instead of `fromInteger` because `read` uses + -- the correct rounding rule. + -- See https://gitlab.haskell.org/ghc/ghc/issues/17231. App IntegerToDouble (IntegerLit n) -> pure (DoubleLit ((read . show) n)) App DoubleShow (DoubleLit n) -> pure (TextLit (Chunks [] (Data.Text.pack (show n)))) diff --git a/dhall/src/Dhall/Eval.hs b/dhall/src/Dhall/Eval.hs index 2c93670..6e33cba 100644 --- a/dhall/src/Dhall/Eval.hs +++ b/dhall/src/Dhall/Eval.hs @@ -519,7 +519,8 @@ eval !env t0 = VPrim $ \case VIntegerLit n -> VDoubleLit (read (show n)) -- `(read . show)` is used instead of `fromInteger` - -- because `read` uses the correct rounding rule + -- because `read` uses the correct rounding rule. + -- See https://gitlab.haskell.org/ghc/ghc/issues/17231. n -> VIntegerToDouble n Double -> VDouble