I have a question about Parsec refactoring to use an interface Applicative. Suppose I have a parser using a monadic interface as follows:
filePath0 :: GenParser Char st Info
filePath0 = do
optional (string "./")
r <- artist
slash
l <- album
slash
t <- track
return $ Song r l t
I would like to turn it into something like this:
filePath :: GenParser Char st Info
filePath = Song <$> artist <*> album <*> track
But, as you can see, this is not complete. My question is: where in this refactoring version would I insert a parser optional (string "./")and slash?
source
share