elm-bridge icon indicating copy to clipboard operation
elm-bridge copied to clipboard

More readable output

Open emanuelkoczwara opened this issue 9 years ago • 4 comments

Hello,

Is it possible to produce more readable output? It would be great to have these improvements:

  • no redundant brackets
  • space before colon in type definition
  • (=>) used in encoder instead of (,)
  • 'val' replaced by one letter variable like 'o'
  • import Json.Encode as E, Json.Decode as D and Json.Helpers as H
  • use (|:) from Json.Decode.Extra instead of 'andThen' and chained lambda

emanuelkoczwara avatar Feb 27 '16 15:02 emanuelkoczwara

That certainly is possible but some points, especially the part about removing redundant brackets, will result in a lot of work.

I toyed with the idea of directly generating Elm's AST and pretty printing it in the end, but while it seemed a lot cleaner, I also felt it would be a ton of work.

Finally, the last point would incur an additional dependency. It would probably be simpler to add it to the json-helpers package.

I'll keep that in mind when I'll work again on the package (it still requires proper aeson 11 support), but pull requests would be very welcome :)

bartavelle avatar Feb 28 '16 08:02 bartavelle

It's too bad that the elm compiler is not published on hackage anymore otherwise we could just use that ast and pretty printer...

agrafix avatar Feb 28 '16 10:02 agrafix

Oh I didn't realize this wasn't even an option :(

bartavelle avatar Feb 28 '16 10:02 bartavelle

See https://github.com/elm-lang/elm-compiler/issues/1300

agrafix avatar Mar 02 '16 17:03 agrafix