File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,13 @@ instance Read Text where
328328-- | @since 1.2.2.0
329329instance Semigroup Text where
330330 (<>) = append
331+ stimes n _ | n < 0 = P. error " Data.Text.Lazy.stimes: given number is negative!"
332+ stimes n a =
333+ let nInt64 = fromIntegral n :: Int64
334+ len = if n == fromIntegral nInt64 && nInt64 >= 0 then nInt64 else P. maxBound
335+ -- We clamp the length to maxBound :: Int64.
336+ -- To tell the difference, the caller would have to skip through 2^63 chunks.
337+ in replicate len a
331338
332339instance Monoid Text where
333340 mempty = empty
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ tl_mappend s = mappend s`eqP` (unpackS . mappend (TL.pack s))
4141t_stimes = \ number -> eq
4242 ((stimes :: Int -> String -> String ) number . unSqrt)
4343 (unpackS . (stimes :: Int -> T. Text -> T. Text ) number . T. pack . unSqrt)
44+ tl_stimes = \ number -> eq
45+ ((stimes :: Int -> String -> String ) number . unSqrt)
46+ (unpackS . (stimes :: Int -> TL. Text -> TL. Text ) number . TL. pack . unSqrt)
4447t_mconcat = (mconcat . unSqrt) `eq` (unpackS . mconcat . L. map T. pack . unSqrt)
4548tl_mconcat = (mconcat . unSqrt) `eq` (unpackS . mconcat . L. map TL. pack . unSqrt)
4649t_mempty = mempty === (unpackS (mempty :: T. Text ))
@@ -76,6 +79,7 @@ testInstances =
7679 testProperty " t_mappend" t_mappend,
7780 testProperty " tl_mappend" tl_mappend,
7881 testProperty " t_stimes" t_stimes,
82+ testProperty " tl_stimes" tl_stimes,
7983 testProperty " t_mconcat" t_mconcat,
8084 testProperty " tl_mconcat" tl_mconcat,
8185 testProperty " t_mempty" t_mempty,
You can’t perform that action at this time.
0 commit comments