4 ms·
Am I misunderstanding you, or are you extremely misinformed? Elm can definitely consume JSON APIs. https://package.elm-lang.org/packages/elm/json/latest/ https
by Latty 2y ago
Am I misunderstanding you, or are you extremely misinformed? Elm can definitely consume JSON APIs.
https://package.elm-lang.org/packages/elm/json/latest/ https://package.elm-lang.org/packages/elm/json/latest/
https://package.elm-lang.org/packages/elm/http/latest/Http https://package.elm-lang.org/packages/elm/http/latest/Http
- otabdeveloper4 2y agoTechnically it can. In practice it is a massive overhead and defeats the purpose of using Elm in the first place. Their solution is, uhm, to wait until JSON disappears and the problem fixes itself, I kid you not: https://gist.github.com/evancz/1c5f2cf34939336ecb79b97bb89d9da6 https://gist.github.com/evancz/1c5f2cf34939336ecb79b97bb89d9...
- boxed 2y agoOverhead? You mean in CPU time or development time?
- otabdeveloper4 2y agoDevelopment time. "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.
- cies 2y ago> 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.
- otabdeveloper4 2y ago> writing JSON parsers takes time The promise of pure functional programming was to never write a 'JSON parser' by hand ever again. (Among other things.) The paradigm failed because people in charge of Haskell and Elm and other similar languages failed at their job.
- cies 2y agoWe parse JSON all the time, there are even ways to generate an JSON-parser-in-Elm for you based on an example! 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.
- Latty 2y agoWhat? I've written a bunch of Elm doing JSON parsing and this just isn't true at all. Writing the decoders isn't hard and gives you nice typed and consistent data formats, which is extremely useful. 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.