http-api-data icon indicating copy to clipboard operation
http-api-data copied to clipboard

toUrlPiece and parseUrlPiece are not reversible

Open roelvandijk opened this issue 8 months ago • 2 comments

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.

roelvandijk avatar Jun 04 '25 13:06 roelvandijk