Skip to content

Commit b653fe4

Browse files
committed
Be abstract of the implementation of Integer.
The constructors of `Integer` and the module they are exported from all changed between GHC 8 and 9.
1 parent 9deed15 commit b653fe4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Data/Text.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ import Data.Word (Word8)
261261
import Foreign.C.Types
262262
import GHC.Base (eqInt, neInt, gtInt, geInt, ltInt, leInt)
263263
import qualified GHC.Exts as Exts
264-
import GHC.Int (Int8, Int (I#))
265-
import GHC.Num.Integer (Integer(IS, IP, IN))
264+
import GHC.Int (Int8)
266265
import GHC.Stack (HasCallStack)
267266
import qualified Language.Haskell.TH.Lib as TH
268267
import qualified Language.Haskell.TH.Syntax as TH
@@ -365,10 +364,11 @@ instance Semigroup Text where
365364

366365
-- | Beware: this function will evaluate to error if the given number does
367366
-- not fit into an @Int@.
368-
stimes howManyTimes = case P.toInteger howManyTimes of
369-
IS howManyTimesInt# -> replicate (I# howManyTimesInt#)
370-
IP _ -> P.error "`Data.Text.stimes`: given number does not fit into an `Int`!"
371-
IN _ -> P.const empty
367+
stimes howManyTimes =
368+
let howManyTimesInt = P.fromIntegral howManyTimes :: Int
369+
in if P.fromIntegral howManyTimesInt == howManyTimes
370+
then replicate howManyTimesInt
371+
else P.error "`Data.Text.stimes`: given number does not fit into an `Int`!"
372372

373373
sconcat = concat . NonEmptyList.toList
374374

0 commit comments

Comments
 (0)