dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

Keep comments in Unions

Open basile-henry opened this issue 4 years ago • 4 comments

From https://twitter.com/Profpatsch/status/1383750764472930312?s=20

This:

<
Foo | 
-- Bar does quux
Bar 
>

Formats to:

< Foo | Bar >

basile-henry avatar Apr 18 '21 12:04 basile-henry

We'd need to change the Union encoding similarly to what we already have for Record:

https://github.com/dhall-lang/dhall-haskell/blob/0b66d50bf02b5a4e6cd95c84edffbad11181f9f9/dhall/src/Dhall/Syntax.hs#L582-L583

https://github.com/dhall-lang/dhall-haskell/blob/0b66d50bf02b5a4e6cd95c84edffbad11181f9f9/dhall/src/Dhall/Syntax.hs#L574-L577

We can't use RecordField directly though, since we don't always have an Expr "value" that we can store in it – we only have a Maybe Expr.

sjakobi avatar Apr 19 '21 09:04 sjakobi

I can have a go at this

basile-henry avatar Apr 19 '21 10:04 basile-henry

@basile-henry That would be great! :)

sjakobi avatar Apr 19 '21 10:04 sjakobi

I found another one:

[ bins.emacsclient
, "--create-frame"
, "--eval"
-- TODO: this obviously fails if the mail address contains "
, "(url-mailto (url-generic-parse-url \"\${1}\"))"
]

loses the comment in lists and

[ bins.emacsclient
, "--create-frame"
, "--eval"
, -- TODO: this obviously fails if the mail address contains "
  "(url-mailto (url-generic-parse-url \"\${1}\"))"
]

does, too (comma before the comment)

Profpatsch avatar May 13 '21 23:05 Profpatsch