Commit 0998ad09 authored by Emily Pillmore's avatar Emily Pillmore Committed by Xia Li-yao
Browse files

parent 1b275ff7

author Emily Pillmore <emily@kadena.io> 1578367360 -0500
committer Emily Pillmore <emilypi@cohomolo.gy> 1612033171 -0500

Add elem combinator to api
parent 66bb23ba
......@@ -185,6 +185,7 @@ module Data.Text
, filter
, breakOnAll
, find
, elem
, partition
-- , findSubstring
......@@ -1503,6 +1504,13 @@ chunksOf k = go
-------------------------------------------------------------------------------
-- ** Searching with a predicate
-- | /O(n)/ The 'elem' function takes a character and a 'Text', and
-- returns 'True' if the element is found in the given 'Text', or
-- 'False' otherwise.
elem :: Char -> Text -> Bool
elem c t = S.any (== c) (stream t)
{-# INLINE elem #-}
-- | /O(n)/ The 'find' function takes a predicate and a 'Text', and
-- returns the first element matching the predicate, or 'Nothing' if
-- there is no such element. Subject to fusion.
......
......@@ -191,6 +191,7 @@ module Data.Text.Lazy
-- * Searching
, filter
, find
, elem
, breakOnAll
, partition
......@@ -1697,6 +1698,13 @@ find :: (Char -> Bool) -> Text -> Maybe Char
find p t = S.findBy p (stream t)
{-# INLINE find #-}
-- | /O(n)/ The 'elem' function takes a character and a 'Text', and
-- returns 'True' if the element is found in the given 'Text', or
-- 'False' otherwise.
elem :: Char -> Text -> Bool
elem c t = S.any (== c) (stream t)
{-# INLINE elem #-}
-- | /O(n)/ The 'partition' function takes a predicate and a 'Text',
-- and returns the pair of 'Text's with elements which do and do not
-- satisfy the predicate, respectively; i.e.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment