halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Generated decoders #98

Closed zwilias closed 6 years ago

zwilias commented 6 years ago

Follow up from Slack discussion.

Generating decoders is wicked cool!

The one for tuples is a little weird, though - it's a little more idiomatic to use Decode.map3 (,,) (Decode.index 0 ..) (Decode.index 1 ..) (Decode.index 2 ..) rather than a series of nested andThen's.

I also mentioned something about andMap, but I've thought about this a little more and think is may be a bad idea. Encouraging people to use pipeline is probably a better idea than using andMap pipelines.

halohalospecial commented 6 years ago

Thanks, @zwilias!

zwilias commented 6 years ago

@halohalospecial Hm, you do need the index thing, still ;)

halohalospecial commented 6 years ago

Nice catch! Thanks again!

Erudition commented 5 years ago

Two things:

  1. I noticed that while you can enable/disable all sorts of autocomplete options in the settings, Decoders/Encoders are not among them.

  2. It seems to assume that the Json.Decode module (or replacement) is imported as Decoder. It's more normal (afaik) to import it as Decode, and that's what I do. So I have to manually change (or F&R) every part of the generated code mentioning Decoders.

  3. The same thing seems to apply to Encoders - which puzzlingly assumes Json.Encode is imported as Value. I guess we like importing things as their primary types or something?

Okay, three things.