by Latty · 2y ago · 0 comments
https://package.elm-lang.org/packages/elm/json/latest/ https://package.elm-lang.org/packages/elm/http/latest/Http
Their solution is, uhm, to wait until JSON disappears and the problem fixes itself, I kid you not: https://gist.github.com/evancz/1c5f2cf34939336ecb79b97bb89d9...
What we do, is leave this up to generated code. We have OpenAPIv3 specs for our APIs and we use the OpenAPIv3-Elm-client-generator to generate the client so we do not deal with JSON parsing etc. ourselves.
"Parse API-produced JSON as a contract" is exactly the kind of programming problem pure functional languages were supposed to solve.
And we're building horrific and error-prone rube-goldberg machines to bolt onto our functional programming languages instead.
You literally make no sense to me. Are you sure we are talking about the same thing?
I mean sure: writing JSON parsers takes time, but once written they are awesome.
I don't know what you mean by "defeats the point of using Elm in the first place", what is the point, and how is it defeated?
If anything, since using Elm I trend towards using things like io-ts or zod to replicate it when I'm working with TypeScript because it is so much better to get that consistency and validation.