Skip to content

Prettier pretty printing#78

Merged
achudnov merged 17 commits intojswebtools:masterfrom
lamdu:prettier
Feb 26, 2016
Merged

Prettier pretty printing#78
achudnov merged 17 commits intojswebtools:masterfrom
lamdu:prettier

Conversation

@Peaker
Copy link
Copy Markdown

@Peaker Peaker commented Feb 25, 2016

Improve the Javascript output to look a lot more like a human wrote it.

Original: https://gist.github.com/Peaker/550f0c0259d87caf6546
Improved: https://gist.github.com/Peaker/13a1e6c6fc216ad61f54

Indent/nest things better.

Allow if/else-if chains to avoid lots of nesting.

If you dislike some of these formatting changes, you could drop specific commits, as you can see they are quite fine-grained :)

@achudnov
Copy link
Copy Markdown
Member

Hi. Thanks a lot. The examples look good. Haven't had a chance to have a look at the changes, nor Travis complaints.

The following is only loosely related to this PR. I'd appreciate if you could pitch in some insight on it while I'm looking at the diffs.

One thing I would probably want to do in the near future is port those changes to the 'es5' branch (https://github.com/jswebtools/language-ecmascript/blob/es5/src/Language/ECMAScript5/PrettyPrint.hs) which would eventually become the next iteration of this package. In that regard, I have two questions:

  1. Have you looked at the pretty printer in 'es5'. It's okay if you haven't, but if you have I'd like your quick opinion on how hard it would be to port those changes there.
  2. I have been looking into providing annotation printing and minification via https://hackage.haskell.org/package/pretty-1.1.3.2/docs/Text-PrettyPrint-Annotated.html which allows to do it in a very nice and modular way. (See also issue Multi-mode pretty-printer #13.) Which would mean using the Hughes&Peyton-Jones printing approach, instead of the one by Wadler-Leijen. I was wondering, but haven't investigated, whether that would negatively impact the quality of printing. So the question specifically for you would be: are you using any features of wl-pprint that aren't in pretty?

@Peaker
Copy link
Copy Markdown
Author

Peaker commented Feb 25, 2016

Oh, didn't know about that branch...

I could port it in the following days, probably.

I am not sure about the pretty package: It seems to lack align and </> and encloseSep.

I willl need to do some research to understand whether the equivalent behavior is possible.

@Peaker
Copy link
Copy Markdown
Author

Peaker commented Feb 25, 2016

https://github.com/Peaker/language-ecmascript/commits/prettier_es5

This one is ported on top of the es5 branch.

achudnov added a commit that referenced this pull request Feb 26, 2016
Prettier pretty printing
@achudnov achudnov merged commit 42cd8fd into jswebtools:master Feb 26, 2016
@achudnov
Copy link
Copy Markdown
Member

Very pretty. Thank you! I've merged the changes against 'es5' as well. Don't worry about porting to pretty: when the time comes, we could just backport the minification to wl-pprint-annotated.

@achudnov
Copy link
Copy Markdown
Member

@Peaker, one more thing, how should I include your copyright in the license and package meta-data? Is "(c) 2016 Eyal Lotem" good? Once you confirm, I'll roll out the update as 0.17.1.0 on Hackage.

@Peaker
Copy link
Copy Markdown
Author

Peaker commented Feb 28, 2016

That's great thanks :)

On Sun, Feb 28, 2016, 17:56 Andrey Chudnov notifications@github.com wrote:

@Peaker https://github.com/Peaker, one more thing, how should I include
your copyright in the license and package meta-data? Is "(c) 2016 Eyal
Lotem" good? Once you confirm, I'll roll out the update as 0.17.1.0 on
Hackage.


Reply to this email directly or view it on GitHub
#78 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants