2

I'm using dhall as a means of defining certain structs which can accept decimals and integers as input. I used the Double type for this as it seemed like a good fit to cover both cases, but I'm running into some issues when rendering them to text where things are converted to using scientific notation:

dhall text <<< 'Double/show 419430400.0'
4.194304e8

and

dhall text <<< 'Double/show 0.0001'
1.0e-4

Is there a way to turn off scientific notation altogether and represent Doubles are Decimals in the conversions to text?

Is there a more appropriate type to use in this case?

  • The only way to change the behaviour of `Double/show` would be to modify the interpreter. Have you considered [extending the interpreter with your own builtin](http://hackage.haskell.org/package/dhall-1.31.1/docs/Dhall-Tutorial.html#g:23) for rendering `Double`s? Alternatively you could define your own type to replace `Double` and your own renderer. Something like `{ x : Integer, resolution : Integer }`. Also feel free to bring this up on https://discourse.dhall-lang.org/… – sjakobi Apr 28 '20 at 12:56
  • 2
    Yeah, currently there is no way to customize how `Double` values are rendered using `Double/show`. In fact, this issue reminds me that the rendering logic is currently underspecified. – Gabriella Gonzalez Apr 28 '20 at 14:34

0 Answers0