Closed fcostantini closed 8 years ago
Thanks @fcostantini
I've pushed a commit which addresses these issues: d3da62a9d449d23b8d665c441468b0ea01de2c7e
The first one was a genuine bug.
The second one is less clear. A conditional statement with no guard is syntactically incorrect. I've modified the pretty printer to generate an error in that case. It is unfortunate that the AST allows things which are not syntactically valid. We really need a better interface for constructing Python code.
Awesome, glad to be helpful. Thanks for the fix!
Can you upload the new version to hackage?
Done. Uploaded to Hackage as 0.5.4. Thanks for your input.
Hi, I'm using your library to generate (somewhat) random Python code and pretty print it. We found that sometimes the generation fails because the Pretty instances are not exhaustive. The 2 exceptions we got were:
There is no pattern for SliceEllipsis, so if we happen to generate one, we get an exception when trying to print it. If I'm not mistaken, this should fix it:
pretty (SliceEllipsis {}) = text "..."
This happens when you try to pretty a Conditional with empty guards. Pretty instance for Conditional is
but since there is no alternative for [], it fails. Since a conditional without guards doesn't make much sense, perhaps it could be prettied as empty :: Doc.
Regards.