@@ -141,6 +141,7 @@ module Data.Text.Lazy
141141 , count
142142
143143 -- * Zipping and unzipping
144+ , zip
144145 , zipWith
145146
146147 -- -* Ordered text
@@ -148,9 +149,8 @@ module Data.Text.Lazy
148149 ) where
149150
150151import Prelude (Char, Bool(..), Int, Maybe(..), String,
151− Eq(..), Ord(..), (++),
152− Read(..), Show(..),
153− (&&), (+), (-), (.),
152+ Eq(..), Ord(..), Read(..), Show(..),
153+ (&&), (+), (-), (.), ($), (++),
154154 flip, fromIntegral, not, otherwise)
155155import qualified Prelude as P
156156import Data.Int (Int64)
@@ -850,6 +850,14 @@ count :: Char -> Text -> Int64
850850count c t = S.count c (stream t)
851851{-# INLINE count #-}
852852
853+-- | /O(n)/ 'zip' takes two 'Text's and returns a list of
854+-- corresponding pairs of bytes. If one input 'Text' is short,
855+-- excess elements of the longer 'Text' are discarded. This is
856+-- equivalent to a pair of 'unpack' operations.
857+zip :: Text -> Text -> [(Char,Char)]
858+zip a b = S.unstreamList $ S.zipWith (,) (stream a) (stream b)
859+{-# INLINE [0] zip #-}
860+
853861-- | /O(n)/ 'zipWith' generalises 'zip' by zipping with the function
854862-- given as the first argument, instead of a tupling function.
855863zipWith :: (Char -> Char -> Char) -> Text -> Text -> Text