rowtype-yoga / pose

24 stars 1 forks source link

Formatting of records in types #6

Open wclr opened 3 years ago

wclr commented 3 years ago

Current formatting of type records:

type Some
  = { name :: String
    , desc :: String
    , details :: String
    }

Here equality sign stands out too much and looks a bit clumsy, and the whole seems to be not well aligned.

But this seems to be more well-aligned :

type Some =
  { name :: String
  , desc :: String
  , details :: String
  }

It resembles with ADT formatting:

data Some
  = Name String
  | String
  | Details String  

Btw tidy uses the former (proposed here) way. At the same time pose now better (then tidy) formats records in ADT:

data X
  = Some
    { x :: String
    }
  | Other
    { y :: Int
    }

So this should not be a subject for change. I currently prefer to use pose rather than tidy.

i-am-the-slime commented 3 years ago

I agree this would be better, let me know if you need help with the PR!

wclr commented 3 years ago

I agree this would be better, let me know if you need help with the PR!

To speed up things, you could point me out to the code where this way of formatting is defined:

type Some
  = { name :: String
wclr commented 2 years ago

@i-am-the-slime did you miss my request?

i-am-the-slime commented 2 years ago

@wclr Hey, yes I did miss it. I was not very online in the past few weeks.

Check out the new README for some help with contributing.

As for where to find out what affects the code you meant you can try here: https://github.com/rowtype-yoga/pose/blob/main/packages/core/src/Pose/Format.purs#L411

But in general, since all functions just produce strings, I suggest to just put some <> "dembowski" in places that you suspect might be formatting what you're after and then see how the output of the golden tests changes.