Attoparsec provides the function takeWhile1
that consumes at least one character.
However, there is no analog for skipWhile
. How can I implement this function skipWhile1
?
Note: This question intentionally shows no research effort as it was answered Q&A-Style.
Another possible implementation:
This might actually be faster than @Uli's answer because
takeWhile
builds a result string, whereasskipWhile
doesn't. Laziness might make them equivalent (ie. maybetakeWhile
doesn't actually build the string if you don't use it); I can't test at the moment to verify this.You can use
Control.Monad.void
together withtakeWhile1
to simply ignore the result: