http-api-data
http-api-data copied to clipboard
toUrlPiece and parseUrlPiece are not reversible
x :: Double
x = 9.0e3
t :: Text
t = toUrlPiece x
-- t == "9.0e-3"
x' :: Either Text Double
x' = parseUrlPiece t
-- x' == Right 9.000000000000001e-3
isReversible :: Bool
isReversible = Right x == x'
-- isReversible == False
The underlying issue is probably in rational :: Fractional a => Reader a not being compatible with show :: Double -> String.