How to use Control.Monad.State with Parsec?
问题 I'm surprised that I could not find any info on this. I must be the only person having any trouble with it. So, let's say I have a dash counter. I want it to count the number of dashes in the string, and return the string. Pretend I gave an example that won't work using parsec's state handling. So this should work: dashCounter = do str <- many1 dash count <- get return (count,str) dash = do char '-' modify (+1) And indeed, this compiles. Okay, so I try to use it: :t parse dashCounter "" "----