on master help sign in
Use `truncate` instead of `floor` in Integral instances
014ab56Chris Wong
Data/Aeson/Types/Instances.hs+2−2
@@ -311,7 +311,7 @@ instance ToJSON Integer where
311-- specifying a scientific number with a big exponent like
311-- specifying a scientific number with a big exponent like
312-- @1e1000000000@.
312-- @1e1000000000@.
313instance FromJSON Integer where
313instance FromJSON Integer where
314− parseJSON = withScientific "Integral" $ pure . floor
314+ parseJSON = withScientific "Integral" $ pure . truncate
315 {-# INLINE parseJSON #-}
315 {-# INLINE parseJSON #-}
316
316
317instance ToJSON Int8 where
317instance ToJSON Int8 where
@@ -1614,5 +1614,5 @@ parseRealFloat expected v = typeMismatch expected v
1614{-# INLINE parseRealFloat #-}
1614{-# INLINE parseRealFloat #-}
1615
1615
1616parseIntegral :: Integral a => String -> Value -> Parser a
1616parseIntegral :: Integral a => String -> Value -> Parser a
1617−parseIntegral expected = withScientific expected $ pure . floor
1617+parseIntegral expected = withScientific expected $ pure . truncate
1618{-# INLINE parseIntegral #-}
1618{-# INLINE parseIntegral #-}