Comments (11)
Should we implement it?
No. Causes diff amplification. For debatable benefit. Tweag's style guide warns against this.
from ormolu.
Causes diff amplification. For debatable benefit
I've said it before, I'll say it again. The only way to align code vertically is elastic tabstops. But until all the tooling decides to support it, we're stuck with not aligning things.
PS: to be fair, github has an option to ignore whitespace changes, which may be able to mask this sort of changes, so aligning with a formatter + this option may make vertical-alignment-by-whitespace (but it's only really practical if all other git tools do it). But don't get me started on how obnoxious relying on monospace fonts for alignment is.
from ormolu.
Do we believe it is the role of a formatter to change line-breaks?
If so, should it only add line breaks for long lines, or also remove line breaks for short lines?
In the latter case, what if I write
foo =
bar $
baz $
tlw
Will Ormolu want to change this to
foo = bar $ baz $ tlw
?
from ormolu.
At this point we know little about actual layouting that it'll be doing. Although I think that there should be one canonical rendition per given AST (module source span info). That means that it may change that definition to put all applications on the same line.
from ormolu.
Actually I missed that @facundominguez started defining this sort of thing. I think it's too early to do this, we might just prefer whatever flows more naturally from implementation. I personally don't care much, if only the style is consistent.
from ormolu.
I don't have an opinion on what the formatter should do with line breaks.
I think it's too early to do this, we might just prefer whatever flows more naturally from implementation.
I'm not sure this is a good idea. We need to discover the constraints on how we want to format. So far we only have the requirement of making the format diff-friendly, which we need to make more precise.
We can't discover this without examples. Would you be happy if the formatter produced the output as I have written it in the examples?
You say the style needs to be consistent. How about we go into spelling what consistent means for formatting Haskell code?
(module source span info).
What does this mean?
from ormolu.
What does this mean?
A typo, should be "modulo ...".
Would you be happy if the formatter produced the output as I have written it in the examples?
Yes, I like the style.
from ormolu.
Does vertical alignment make code easier to read?
data A = A
{ aField :: Int
. anotherField :: String
}
f (Just x) = x
f Nothing = 0
Should we implement it?
from ormolu.
If we are pretty-printing ASTs, here are a few things which we should think about:
somefunction $
someBlock
vs
some $
chain $
of $
functions
Also, whitespacey bracket vs pointy bracket
do
{ some
, instructions
}
vs
do
some
instructions
from ormolu.
some $
chain $
of $
functions
vs
some $ chain $ of $
functions
vs
some $
chain $
of $
functions
from ormolu.
This one is old and dead. I'm going to close it. Now we have a test suite and we can add concerte examples there very easily. I imagine quite soon there will be concrete implementation for all constructs.
from ormolu.
Related Issues (20)
- Interesting comment placements in various scenarios HOT 1
- Idempotency check fails for comment in import list
- Format existential data types better HOT 1
- Overloaded labels (hash) syntax gets formatted with space after hash sign HOT 2
- Support for literate Haskell HOT 3
- Formatting {-# LANGUAGE #-} repeats previous comments like vim modelines HOT 1
- Add `-R, --recursive` option for implying `--mode inplace ` and all `*.hs` file under given directory HOT 2
- Language pragma `JavaScriptFFI` can't be parsed
- Formatted file has invalid syntax for the associated type synonym defaults HOT 2
- Format selection containing `->` HOT 1
- Ormolu.Fixity doesn't compile HOT 3
- Support “fine-grained” operator precedence
- Extra indentation for hanging `\case` statements with `(&)` HOT 1
- Ormolu incorrectly inserts parentheses around type-level multiplication HOT 4
- Consider supporting fixity namespacing HOT 1
- Compact single-line expression with dangling close paren HOT 2
- Make it clear that configuration files must end with a newline HOT 1
- Support a `--compatible` flag HOT 6
- Provide a way to determine which version of ormolu is formatting a document? HOT 1
- Format multiple files in parallel HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ormolu.