avh4 / avh4/elm-format

Composed extensible record types should support multiline formatting

Open
#508 7 comments 0 reactions 0 assignees View on GitHub
discussion
Dominant language
Haskell
Stars
1.3k
Forks
147
PR merge metrics
No merged PRs in 30d

Description

I use the extensible record syntax to compose larger records types. Why I do this is a long story, but mostly it is related to modularity.

## Example
Example of composing two records:
```elm
type alias Part1 a =
{ a
| part1 : Int
}

type alias Part2 a =
{ a
| part2 : String
}

-- The composed record looks like this

type alias Composed =
Part1 ( Part2 {} )

```

Now, when composing many parts I like to split the declaration on multiple lines:

This would be one way to do this:
```elm
type alias Composed =
Part1
( Part2
( Part3
( Part4 {}
)
)
)

```

However, with 20 parts it becomes very difficult to read so I usually do more of a "lisp" style. Maybe not very elegant, but it works. It is easy to read and modify.

Something like this:
```elm
type alias Composed =
Part1
( Part2
( Part3
( Part4 {}
)))
```
Sometimes the parts also have parameters:
```elm
type alias Composed =
Part1
( Part2 Int Msg
( Part3 Msg
( Part4 {}
)))
```
## Problem

`elm-format` implodes the above to one line, which makes it really difficult to maintain or read.

I don't know which coding style is correct, but I certainly prefer the "lisp" style when there are many parts.

Any thoughts on this? Is this something that should be fixed in elm-format?

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no source file or test. Begin by reproducing the multiline extensible-record examples with elm-format, then trace the formatter entry point handling these type-alias declarations; done requires an agreed multiline formatting rule and coverage for the reported examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
elm, haskell
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.