Commits

Bryan O'Sullivan  committed 02c12f4

Use realToFrac instead of (fromRational . toRational).

  • Participants
  • Parent commits a1b1ef7

Comments (0)

Files changed (3)

File Data/Aeson/Types.hs

     {-# INLINE parseJSON #-}
 
 instance ToJSON Float where
-    toJSON = Number . fromRational . toRational
+    toJSON = Number . realToFrac
     {-# INLINE toJSON #-}
 
 instance FromJSON Float where

File benchmarks/AesonEncode.hs

             _        -> error $ "failed to read " ++ show arg
     loop 0 r
     delta <- flip diffUTCTime start `fmap` getCurrentTime
-    let rate = fromIntegral count / (fromRational . toRational) delta :: Double
+    let rate = fromIntegral count / realToFrac delta :: Double
     putStrLn $ "  " ++ show delta
     putStrLn $ "  " ++ show (round rate) ++ " per second"

File benchmarks/AesonParse.hs

     (good, _) <- loop 0 0
     delta <- flip diffUTCTime start `fmap` getCurrentTime
     putStrLn $ "  " ++ show good ++ " good, " ++ show delta
-    let rate = fromIntegral count / (fromRational . toRational) delta :: Double
+    let rate = fromIntegral count / realToFrac delta :: Double
     putStrLn $ "  " ++ show (round rate) ++ " per second"