Haskell beginner here.
Say that I have a parser that I supply with some information and it returns the results of parsing a section and the info needed for the next section.
readSection :: Info -> Parser (Section, Info)
I was hoping to be able to parse multiple sections using the many combinator, but I can't get the types to work. I need some way of having a parser take in the Info of the previous computation. This structure reminds me of a fold (since the previous results can just be stored in the accumulator), but I'm not sure how to apply that here.
readSections :: Info -> Parser [Section]
readSections startInfo = do
let parser = readSection startInfo
-- ???
return $ many readSection
Maybe there's a better way of doing something like this, so any guidance would be greatly appreciated. Thanks!