Skip to content

Commit f224f26

Browse files
authored
Merge pull request #597 from olafurpg/gsoc-scalafmt
Add abstract for scalafmt gsoc project
2 parents ee0f676 + 11d7b35 commit f224f26

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

gsoc/2017.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ the JVM) and web-based visualization libraries such as d3.
184184

185185
Supervised by [@julienrf](https://github.com/julienrf)
186186

187+
### New line-wrapping algorithm for scalafmt
188+
189+
[Scalafmt](https://olafurpg.github.io/scalafmt/) is a code formatter for Scala.
190+
A key feature of scalafmt is that users can define a maximum width (for example 80 characters)
191+
so that long code lines get automatically wrapped into shorter lines.
192+
Currently, scalafmt uses a [token-based best-first search algorithm](https://geirsson.com/assets/olafur.geirsson-scalafmt-thesis.pdf) to wrap long lines.
193+
Both [dartfmt](http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/)
194+
and [clang-format](https://www.youtube.com/watch?v=s7JmdCfI__c) use a similar approach.
195+
This token-based best-first algorithm has [known issues](https://olafurpg.github.io/scalafmt/#Deeplynestedcode) in scalafmt.
196+
197+
The goal of this project would be to explore and implement an alternative line wrapping algorithm for scalafmt.
198+
One promising alternative is the [dynamic-programming algorithm employed by rfmt](https://www.researchgate.net/profile/Phillip_Yelland/publication/284724851_A_New_Approach_to_Optimal_Code_Formatting/links/5657f1e608ae4988a7b58558.pdf)
199+
(see [Python implementation](https://github.com/google/rfmt)).
200+
Another promising algorithm is Philip Wadler's ["prettier printer"](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf).
201+
The prettier-printer algorithm has been successfully employed by the [prettier](https://github.com/jlongster/prettier) JavaScript formatter.
202+
203+
Supervised by [@olafurpg](https://github.com/olafurpg)
204+
187205
*... Mentors: please insert your projects here. You can use the following template and submit a PR [here](https://github.com/scala/scala-lang). Note that student applications will end on April 3, 2017 ...*
188206

189207
### *Project name*

0 commit comments

Comments
 (0)