|
stimes howManyTimes |
|
| howManyTimes < 0 = P.error "Data.Text.stimes: given number is negative!" |
|
| otherwise = |
|
let howManyTimesInt = P.fromIntegral howManyTimes :: Int |
|
in if P.fromIntegral howManyTimesInt == howManyTimes |
|
then replicate howManyTimesInt |
|
else P.error "Data.Text.stimes: given number does not fit into an Int!" |
It is possible to go a to Int to a losslessly but have a different numeric value than the Int. Word is the most common example of such a type.
So we currently get incorrect results. As an example,
stimes (maxBound :: Word) "a"
-- ✅ fromIntegral (fromIntegral (maxBound :: Word) :: Int) == (maxBound :: Word)
= replicate (-1) "a"
= ""
text/src/Data/Text.hs
Lines 379 to 385 in 1994b13
It is possible to go
atoInttoalosslessly but have a different numeric value than theInt.Wordis the most common example of such a type.So we currently get incorrect results. As an example,