@@ -115,7 +115,7 @@ module Data.Text
115 , unwords
115 , unwords
117 -- * Predicates
117 -- * Predicates
118− -- , isPrefixOf
118+ , isPrefixOf
119 -- , isSuffixOf
119 -- , isSuffixOf
120 -- , isInfixOf
120 -- , isInfixOf
@@ -143,7 +143,7 @@ module Data.Text
143 , -- sort
143 , -- sort
146−import Prelude (Char, Bool, Functor(..), Int, Maybe(..), String,
146+import Prelude (Char, Bool(..), Functor(..), Int, Maybe(..), String,
147 Eq, (==), (++), error,
147 Eq, (==), (++), error,
148 Read(..), Show(..),
148 Read(..), Show(..),
149 (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), ($),
149 (&&), (||), (+), (-), (<), (>), (<=), (>=), (.), ($),
@@ -836,5 +836,14 @@ unwords :: [Text] -> Text
836unwords = intercalate (singleton ' ')
836unwords = intercalate (singleton ' ')
837{-# INLINE unwords #-}
837{-# INLINE unwords #-}
839+isPrefixOf :: Text -> Text -> Bool
840+isPrefixOf a@(Text _ _ alen) b@(Text _ _ blen) = alen <= blen && loop 0 0
841+ where loop !i !j | i >= alen = True
842+ | c == e = loop (i+d) (j+f)
844+ where (c,d) = iter a i
846+{-# INLINE [1] isPrefixOf #-}
839errorEmptyList :: String -> a
848errorEmptyList :: String -> a
840errorEmptyList fun = error ("Data.Text." ++ fun ++ ": empty list")
849errorEmptyList fun = error ("Data.Text." ++ fun ++ ": empty list")