Coder Social home page Coder Social logo

Comments (11)

mboes avatar mboes commented on August 22, 2024 1

Should we implement it?

No. Causes diff amplification. For debatable benefit. Tweag's style guide warns against this.

from ormolu.

aspiwack avatar aspiwack commented on August 22, 2024 1

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.

aspiwack avatar aspiwack commented on August 22, 2024

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.

mrkkrp avatar mrkkrp commented on August 22, 2024

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.

mrkkrp avatar mrkkrp commented on August 22, 2024

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.

facundominguez avatar facundominguez commented on August 22, 2024

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.

mrkkrp avatar mrkkrp commented on August 22, 2024

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.

facundominguez avatar facundominguez commented on August 22, 2024

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.

aspiwack avatar aspiwack commented on August 22, 2024

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.

facundominguez avatar facundominguez commented on August 22, 2024
some $
chain $
of $
functions

vs

some $ chain $ of $
functions

vs

some $
  chain $
    of $
      functions

from ormolu.

mrkkrp avatar mrkkrp commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.