I would like to parse a list of Haskell statements. For instance, suppose I have the following code:
let a = b
c = e
out <- return 3
I'd like a function, for instance parseStmts, which can return this in some parsed format.
I've looked into haskell-src-exts and saw parseStmt. This works for a single statement. It has type parseStmt :: String -> ParseResult Stmt, and if you try parseStmt "let a = 3", the result is a successful ParseOk. However, if you provide multiple statements, this function complains because there is more than one statement in the string.
How do I parse multiple statements, without wrapping them in a do block? Alternatively, how can I find the places in a string which are separations of Haskell statements, so I can separate them and then use parseStmt from haskell-src-exts?
Thanks!