Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with spaces inside of parens #7

Closed
avh4 opened this issue Oct 20, 2015 · 7 comments
Closed

How to deal with spaces inside of parens #7

avh4 opened this issue Oct 20, 2015 · 7 comments

Comments

@avh4
Copy link
Owner

avh4 commented Oct 20, 2015

Parens are used in many different ways. Should the same rule apply to all? What should the rules be?

module Main (parens, here, And(Here)) where

import Foo exposing (moreParens, More(..))

type MyType
    = A (Int, Float)

fn (tuple,pattern) =
    (1, 2, 3)
        |> (\(a, b, c) -> a)
        |> (+) 10
@avh4 avh4 added this to the MVP milestone Oct 20, 2015
@avh4
Copy link
Owner Author

avh4 commented Oct 20, 2015

@Apanatshka:

I don’t know what to think of removing the spaces between the round brackets and the imports in the list.

@rtfeldman:

The rule of thumb that I've followed is "spaces for data structures" - e.g.

{ foo = 1, bar = 2 }
[ foo, bar ]
( foo, bar )

...but not

(foo bar)
(foo == bar)

However, I wonder if a simpler rule might be "spaces if there are commas" - in other words, all of the above cases plus import lists.

From an end user perspective, I like the simplicity of that rule. Thoughts?

@Apanatshka
Copy link

I think the best way to resolve this is to try some different options.

@rtfeldman
Copy link

Since we need to pick one to start, I'd say let's start with "spaces if there are commas," in other words:

( foo, bar )
(foo bar)
(foo == bar)

...or perhaps more precisely "spaces if there could be commas," so in other words:

import Foo exposing ( bar )
import Bar exposing ( baz, qux )

I've never tried that style with imports, but at first glance I like how it looks!

@avh4
Copy link
Owner Author

avh4 commented Oct 20, 2015

Okay, let's try @rtfeldman's most recent suggestion and see how it looks on real examples.

@avh4
Copy link
Owner Author

avh4 commented Oct 21, 2015

Another possibility could be: no spaces if the parens are within a single line, spaces if they span multiple lines, so:

module Foo (a, b) where

module Foo
    ( a
    , b
    ) where

(foo == bar)

( foo
    == bar
)

(foo, bar)

( foo
, bar
)

@rtfeldman
Copy link

I could see that, although I'd still keep the spaces for tuples in order to be consistent with the spaces lists and records have.

I do like tuples with spaces and function application without, because it helps distinguish the two in a more identifiable way at a glance than a tiny comma.

@avh4
Copy link
Owner Author

avh4 commented Oct 27, 2015

Will implement #20 for now.

@avh4 avh4 closed this as completed Oct 27, 2015
avh4 added a commit that referenced this issue Mar 20, 2017
kutyel pushed a commit to kutyel/elm-format that referenced this issue Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants