michaelt / text-pipes

Text pipes
BSD 3-Clause "New" or "Revised" License
10 stars 13 forks source link

`count` is wrong #9

Closed michaelt closed 8 years ago

michaelt commented 10 years ago
 > Text.count "si" (each ["Mis", "siss", "ippi"]) >>= print 
 1
 > Text.count "si" (each ["Mis", "sissippi"]) >>= print 
 2

This may relate to the difficulty defining things like replace. Bytes.count of course just looks for the Word8. Like Bytes.splits we split on a Char; but the similar function in Data.Text is

 T.splitOn :: Text -> Text -> [Text]

suggesting

 Text.splits :: Text -> Producer Text m r -> FreeT (Producer Text m) m r

Several functions in Data.Text are defined in terms of the unexported indices Data.Text.Search; it might be possible to emulate the Lazy version.