@@ -110,7 +110,7 @@ module Data.Text
110110
111111 -- ** Breaking into lines and words
112112 , words
113− -- , lines
113+ , lines
114114
115115 -- * Predicates
116116 -- , isPrefixOf
@@ -626,6 +626,8 @@ elemIndex c t = S.elemIndex c (stream t)
626626zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text
627627zipWith f t1 t2 = unstream (S.zipWith f (stream t1) (stream t2))
628628
629+-- | /O(n)/ Breaks a 'Text' up into a list of words, delimited by 'Char's
630+-- representing white space.
629631words :: Text -> [Text]
630632words (Text arr off len) = loop0 off off
631633 where
@@ -641,5 +643,17 @@ words (Text arr off len) = loop0 off off
641643 c = arr `A.unsafeIndex` n
642644{-# INLINE words #-}
643645
646+-- | /O(n)/ Breaks a 'Text' up into a list of 'Text's at
647+-- newline 'Char's. The resulting strings do not contain newlines.
648+--
649+lines :: Text -> [Text]
650+lines ps
651+ | null ps = []
652+ | otherwise = case search ps of
653+ Nothing -> [ps]
654+ Just n -> take n ps : lines (drop (n+1) ps)
655+ where search = elemIndex '\n'
656+{-# INLINE lines #-}
657+
644658errorEmptyList :: String -> a
645659errorEmptyList fun = error ("Data.Text." ++ fun ++ ": empty list")