Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Data/Text/Lazy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ module Data.Text.Lazy
, splitAt
, span
, spanM
, spanEnd
, spanEndM
, breakOn
, breakOnEnd
Expand Down Expand Up @@ -230,8 +231,10 @@ import Data.Bits (finiteBitSize, toIntegralSized)
import Data.Int (Int64)
import qualified Data.List as L hiding (head, tail)
import Data.Char (isSpace)
import Data.Coerce (coerce)
import Data.Data (Data(gfoldl, toConstr, gunfold, dataTypeOf), constrIndex,
Constr, mkConstr, DataType, mkDataType, Fixity(Prefix))
import Data.Functor.Identity (Identity(..))
import Data.Binary (Binary(get, put))
import Data.Binary.Put (putBuilder)
import Data.List.NonEmpty (NonEmpty(..))
Expand Down Expand Up @@ -1517,6 +1520,13 @@ spanM p t0 = go t0
else pure (chunk t1 empty, Chunk t2 ts)
{-# INLINE spanM #-}

-- | Split a @t@ into a pair @(t1, t2)@ where @t2@ is the longest suffix of @t@
-- whose characters satisfy the given predicate.
--
-- @since 2.1.5
spanEnd :: (Char -> Bool) -> Text -> (Text, Text)
spanEnd = coerce (spanEndM :: (Char -> Identity Bool) -> Text -> Identity (Text, Text))

-- | /O(length of suffix)/ 'spanEndM', applied to a monadic predicate @p@,
-- a text @t@, returns a pair @(t1, t2)@ where @t2@ is the longest suffix of
-- @t@ whose elements satisfy @p@, and @t1@ is the remainder of the text.
Expand Down
Loading