I was surprised not to find a function in the library to split a text on the first match of a character/text/predicate, with the matched part discarded.
This is not difficult to write using breakOn and drop, but I think a function implemented with the internals of the library might have better performance.
split1 :: Char -> Text -> (Text, Text)
split1 c = (id *** drop 1) . (breakOn $ singleton c)
See a similar function (previously called splitOnce) in the byteslice package, and a question on Stack Overflow about splitAtfirst.
I was surprised not to find a function in the library to split a text on the first match of a character/text/predicate, with the matched part discarded.
This is not difficult to write using
breakOnanddrop, but I think a function implemented with the internals of the library might have better performance.See a similar function (previously called
splitOnce) in thebyteslicepackage, and a question on Stack Overflow aboutsplitAtfirst.