generic implementation of Bits.toIntegralSized

22 Jun
2020
22 Jun
'20
5:23 a.m.
Documentation of toIntegralSized gives following generic implementation: toIntegral :: (Integral a, Integral b) => a -> Maybe b toIntegral x | toInteger x == y = Just (fromInteger y) | otherwise = Nothing where y = toInteger x I expect that (toInteger x == toInteger x) is always true because of referential transparency, right? I assume the intent was to compare the Integer representations of the parameter and the result. Maybe it should be this way: toIntegral :: (Integral a, Integral b) => a -> Maybe b toIntegral x | toInteger x == toInteger y = Just y | otherwise = Nothing where y = fromInteger $ toInteger x
1793
Age (days ago)
1793
Last active (days ago)
0 comments
1 participants
participants (1)
-
Henning Thielemann