@@ -635,7 +635,7 @@ mapAccumR f s t = case uncons t of
635635-- | /O(n*m)/ 'replicate' @n@ @t@ is a 'Text' consisting of the input
636636-- @t@ repeated @n@ times. Subject to fusion.
637637replicate :: Int64 -> Text -> Text
638−replicate n t = unstream (S.replicateI (fromIntegral n) (S.stream t))
638+replicate n t = unstream (S.replicateI n (S.stream t))
639639{-# INLINE replicate #-}
640640
641641-- | /O(n)/ 'replicateChar' @n@ @c@ is a 'Text' of length @n@ with @c@ the
@@ -873,7 +873,10 @@ tails ts@(Chunk t ts')
873873-- are slices of the original.
874874
875875-- | /O(m)*O(n)/ Break a 'Text' into pieces separated by the first
876−-- 'Text' argument, consuming the delimiter. Examples:
876+-- 'Text' argument, consuming the delimiter. An empty delimiter is
877+-- invalid, and will cause an error to be raised.
878+--
879+-- Examples:
877880--
878881-- > split "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"]
879882-- > split "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""]
@@ -887,7 +890,7 @@ split :: Text -- ^ Text to split on
887890 -> Text -- ^ Input text
888891 -> [Text]
889892split pat src0
890− | l == 0 = [src0]
893+ | l == 0 = emptyError "split"
891894 | l == 1 = splitWith (== (head pat)) src0
892895 | otherwise = go src0
893896 where
@@ -910,7 +913,8 @@ split pat src0
910913-- and consuming the delimiter. The last element of the list contains
911914-- the remaining text after the number of times to split has been
912915-- reached. A value of zero or less for @k@ causes no splitting to
913−-- occur.
916+-- occur. An empty delimiter is invalid, and will cause an error to
917+-- be raised.
914918--
915919-- Examples:
916920--
@@ -926,8 +930,9 @@ splitTimes :: Int64 -- ^ Maximum number of times to split
926930 -> Text -- ^ Input text
927931 -> [Text]
928932splitTimes k pat src0
929− | k <= 0 || l == 0 = [src0]
930− | otherwise = go k src0
933+ | k <= 0 = [src0]
934+ | l == 0 = emptyError "splitTimes"
935+ | otherwise = go k src0
931936 where
932937 l = length pat
933938 go !i src = search 0 src