From c314ce25e093195073bd9f79b2e1fc98909a6486 Mon Sep 17 00:00:00 2001 From: Ignat Insarov Date: Sat, 13 Apr 2024 16:33:32 +0700 Subject: [PATCH] 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. --- src/Data/Text.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Data/Text.hs b/src/Data/Text.hs index 5b70f130..b5981e2a 100644 --- a/src/Data/Text.hs +++ b/src/Data/Text.hs @@ -261,8 +261,7 @@ import Data.Word (Word8) import Foreign.C.Types import GHC.Base (eqInt, neInt, gtInt, geInt, ltInt, leInt) import qualified GHC.Exts as Exts -import GHC.Int (Int8, Int (I#)) -import GHC.Num.Integer (Integer(IS, IP, IN)) +import GHC.Int (Int8) import GHC.Stack (HasCallStack) import qualified Language.Haskell.TH.Lib as TH import qualified Language.Haskell.TH.Syntax as TH @@ -365,10 +364,11 @@ instance Semigroup Text where -- | Beware: this function will evaluate to error if the given number does -- not fit into an @Int@. - stimes howManyTimes = case P.toInteger howManyTimes of - IS howManyTimesInt# -> replicate (I# howManyTimesInt#) - IP _ -> P.error "Data.Text.stimes: given number does not fit into an Int!" - IN _ -> P.const empty + stimes howManyTimes = + 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!" sconcat = concat . NonEmptyList.toList