Elm-format: Comments cause the value in record to go line below

Created on 4 Feb 2016  路  6Comments  路  Source: avh4/elm-format

elm-format_all_elm_files_by_amitaibu_ _pull_request__128_ _gizra_elm-hedley

(from here)

discussion duplicate

Most helpful comment

I think the "proper" way should be:

type Unit
  -- metric
  = Cm Float
  | Mm Float
  | M Float
  -- imperial
  | In Float
  | Ft Float

All 6 comments

Can you clarify what part of the code that comment refers to? If it's meant to go with nextPage, then would the following be reasonable?

type alias Model =
  { login : Login.Model
  , -- If the user is anonymous, we want to know where to redirect them.
    nextPage : Maybe Page
  }

Currently elm-format thinks the comment is associated with Login.Model because the comment comes before the comma.

Can you clarify what part of the code that comment refers to?

It refers to the line below it (nextPage).

then would the following be reasonable?

It's looks slightly weird, and not consistent - I'd expect the leading comma before the actual key.
My expectations would be to keep it as is, but of course, I guess it's easier said than done ;)

(p.s. many thanks for this lib - it's awesome!)

Related:

type Unit
    -- metric
  = Cm Float
  | Mm Float
  | M Float
    -- imperial
  | In Float
  | Ft Float

results in

type
  Unit
  -- metric
  = Cm Float
  | Mm Float
  | M Float
    -- imperial
  | In Float
  | Ft Float

(To be fair, I don't know what's the right thing to do here. Particularly where to put the first comment in the first code snippet.)

I think the "proper" way should be:

type Unit
  -- metric
  = Cm Float
  | Mm Float
  | M Float
  -- imperial
  | In Float
  | Ft Float

The original issue about records has been fixed.

The example about type Unit seems contrived, and should be a separate issue if it's still a concern.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yonigibbs picture yonigibbs  路  7Comments

ahstro picture ahstro  路  3Comments

rtfeldman picture rtfeldman  路  7Comments

ahstro picture ahstro  路  4Comments

rtfeldman picture rtfeldman  路  4Comments