Open puffnfresh opened 8 years ago
Thanks @puffnfresh.
I'm not sure how I feel about this.
On the one hand I can see the convenience, but on the other hand the pretty printer assumes that it is given a valid AST.
I think the bigger problem is that we don't have a convenient way to construct ASTs programmatically. Therefore we are currently forced to build the AST values directly, but the AST data type has too much slack in it. It is easy to create ASTs which do not correspond to valid Python parses.
We could patch the pretty printer to allow conveniences, like the one described in this issue. However, that is a bit of a slippery slope, given that there are probably lots of places where such conveniences could be introduced in the pretty printer.
I think a better solution is to add functionality for conveniently building valid ASTs programmatically, and leave the pretty printer to assume that it is given a valid AST.
Cheers, Bernie
@bjpop I agree:
data ClassyBody
= ClassBody (NonEmptyList a)
| ClassBodyPass
I'm thinking of a library of "smart" constructor functions. Perhaps also quasi quotation, as mentioned in https://github.com/bjpop/language-python/issues/13.
Should give:
But currently the "pass" is missing.