Consider the following program:
import Data.Double.Conversion.Convertable
import Data.Text
import qualified Data.Text.Lazy.Builder as TLB
main :: IO ()
main = do
let
x1 :: Text = "I have " <> toExponential 2 (3.14 :: Double) <> " cakes."
x2 :: TLB.Builder = "I have " <> toExponential 2 (3.14 :: Double) <> " cakes."
putStrLn $ show x1
putStrLn $ show x2
The output is ...
"I have 3.14e0 cakes."
"3.14e0 \NUL\NUL\NUL\NUL\NUL\NUL cakes."
The Text instance of Convertable produces correct output, but the Builder instance does not. In some other tests I did the Builder output always gets written to the beginning instead of the correct location.
Consider the following program:
The output is ...
The
Textinstance ofConvertableproduces correct output, but theBuilderinstance does not. In some other tests I did the Builder output always gets written to the beginning instead of the correct location.