purescript-contrib/purescript-parsing

rest primitive String parser

jamesdbrock opened this issue · 3 comments

I needed this rest parser today so I wrote something like it. It's pretty common and I think we should include it in the primitive parsers for Text.Parsing.Parser.String.

-- | Parse and return the rest of the input. Always succeeds.
rest :: forall m. Monad m => ParserT String m String
rest = do
  ParseState input position _ <- get
  set $ ParseState "" (updatePosString position input) true
  pure input

Except we can't write it for StringLike. Are we sure that the StringLike typeclass is a good idea?

rest :: forall m s. StringLike s => Monad m => ParserT s m s

Also take n, drop n.

And takeWhile, dropWhile.