Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upJson.Decoder for objects with more than 8 arguments #514
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Mar 1, 2016
Contributor
You may want to use the (|:) operator: http://package.elm-lang.org/packages/circuithub/elm-json-extra/latest/Json-Decode-Extra#|:.
Generally, for such discussion, please use the mailing list. This issue tracker here serves a different purpose.
|
You may want to use the Generally, for such discussion, please use the mailing list. This issue tracker here serves a different purpose. |
jvoigtlaender
closed this
Mar 1, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
tiziano88
Mar 1, 2016
Thanks @jvoigtlaender, that makes perfect sense, I didn't realise Json.Decode already has an andThen operator, which makes it a Monad and hence also an Applicative Functor already. I have modified my plugin already, emulating an Applicative-style syntax, although it is only bound to the Json.Decode instance (I really wish Elm had HKTs so that this pattern could be generalised).
Apologies for not posting to the appropriate medium, I shall take more care going forward.
tiziano88
commented
Mar 1, 2016
|
Thanks @jvoigtlaender, that makes perfect sense, I didn't realise Json.Decode already has an Apologies for not posting to the appropriate medium, I shall take more care going forward. |
tiziano88 commentedMar 1, 2016
I am working on a plugin to generate protobuf bindings for Elm (https://github.com/tiziano88/elm-protobuf); it uses the
Json.Decodepackage to deserialize JSON into Elm objects, but it is hitting the limitations of theobjectNcombinators in that package; it is not unusual for protobuf objects to have dozens of fields, but theJson.Decodepackage only offers up toobject8as a convienence to build objects from other combinators.I believe if Elm had a way of expressing Applicative Functors, this pattern would fall into that scope (e.g.
obj <$> dec1 <*> dec2 <*> dec3 ...), and there would be no need for all the overloaded versions of this combinator, but currently, it seems inevitable.So my question is: should I rely on some more custom way of deserializing JSON for large objects, or should we increase the number of overloaded
objectN, or something else entirely?Please let me know if you have any suggestions at all, I am happy to discuss alternatives.
See here for an example code generated by the protobuf plugin that uses
object7.