Reputation: 187
I am trying to parse a Haskell source file into an AST. I'm new to parsers so I'm not sure how to make my own. I was just wondering if there is a function that takes a file and returns an AST. I also thought it might work to turn a file into a string using readFile
and then parsing the string, but I still don't know where to go from there. Is there some well-known way to do this? If not, how can I do it myself?
Upvotes: 2
Views: 803
Reputation: 8831
Try Language.Haskell.Meta.Parse. In particular, parseHsModule
will parse an entire module for you. There are also functions for parsing smaller chunks, such as parseExp
which parses an expression.
Upvotes: 3