
On 9/10/10 4:10 PM, Ian Lynagh wrote:
On Thu, Sep 09, 2010 at 11:36:30AM -0700, Bryan O'Sullivan wrote:
On Wed, Sep 8, 2010 at 5:21 PM, wren ng thornton
wrote:
Text: break :: Text -> Text -> (Text, Text) breakBy :: (Char -> Bool) -> Text -> (Text, Text)
Other than that, I do agree with the philosophy of the "deliberate and sensible" differences. Though, given the philosophy that these aren't Char-wise operations, why does Text.breakBy accept a (Char->Bool)? Is this just an optimization for common cases like breaking on Unicode-defined whitespace codepoints?
I kept breakBy in there because it is actually useful. I changed its name because it's by far less common than "I want to break on a string".
That makes sense if considering text in isolation, but as part of a system I would prefer consistent names between []/String, bytestring and text. (It shouldn't necessarily be text that changes, though).
I also wonder if there should be a f :: (Text -> Bool) -> Text -> (Text, Text)
Yes, that was my point. I can see uses for (Text->...), ((Text->Bool)->...), and ((Char->Bool)->...) but the middle one ---which seems to be the closest analogue to String and ByteString--- is missing. The first one is posited as a replacement for the middle one, but it is insufficient since it cannot perform disjunctive searches. When I pointed that out, I was directed to the third one, which is insufficient because I may wish to search for "characters" which are not individual codepoints. Why do we not just have the middle ((Text->Bool)->...) option? The other two options are subsumed by it, so the only reason to define them is (a) because they can be implemented more efficiently, or (b) as mere shorthands for doing the necessary coercions to turn the first argument into the right type of predicate. -- Live well, ~wren