6 ms·
Debugging with Elm 0.18
- zalmoxes 10y agoI've updated a few of my projects to 0.18 over the last couple weeks. The new HTTP library is much better than the one before. Working with Authentication Tokens, decoding errors etc is much easier now. I also welcome the continuous work to remove things which are difficult for beginners and make code less readable, like the backtick syntax and the prime notation. I mostly work with backend code, and I wanted to learn some JS but found the ecosystem hard to swallow. Elm offers a very practical, and quick to get started experience for writing reliable frontend. For a quick win with UI work, also check out the Elm-MDL library. https://debois.github.io/elm-mdl/ https://debois.github.io/elm-mdl/ --- Coincidentally, I was watching MPJ's FunFunFunction today, where he talks about JS libraries that coerce HTTP statuses into JS errors, and he managed to articulate some of my frustrations with elm-lang/http. The library tries to be helpful by returning a `BadStatus (Response String)` error if the status is not a 20x code. An error is what I want sometimes, but far from always. The result is also a string, while most of the API's I interact with return JSON for errors. https://www.youtube.com/watch?v=gRsyY0kzXfw&feature=youtu.be&t=404 https://www.youtube.com/watch?v=gRsyY0kzXfw&feature=youtu.be...
- Skinney 10y agoHttp does allow you to get the raw data and treat it as you will. It also isn't that much code. Check out the custom requests section of the documentation.
- zalmoxes 10y agoRight, I know how to get around this issue when I need to. My point was that the library makes a default assumption which is often enough false. And then I have to change things. Compare this to Go, or even Fetch. You send a request, and you get back a response, with a Body, Headers and Status. A language error type is only expected in case of the request not succeeding, like a timeout. Here, the library makes 2 assumptions. That a non-200 status is an Error, and that the response is a String. These assumptions would be ok in a higher level library someone wanted to build, but as part of a core, they're too high level to work for everyone with the defaults.
- twoquestions 10y agoI'm glad Evan took out some of the Haskellish syntax that non-Haskellers find confusing, like the x' variable names and backtick syntax. The decision to write something with backticks or the pipe operator seemed to be a matter of personal taste, and I like a system where these less-important decisions are already made.
- omouse 10y agoIt didn't confuse me but it did annoy me! The x-prime looked like the elm equivalent of mysql_real_escape from PHP. I've only been using the pipe syntax and this makes things simpler; backticks are special syntax, pipe syntax is just another function.
- tpaksoy 10y agoIt didn't help that the argument order of some functions were specifically written to be used in backticks (like `andThen`). So I had to litter `flip` everywhere to use the pipe syntax. Evan flipped the arguments in 0.18 and now I can just `:%s/flip andThen/andThen`.
- ronjouch 10y agoAlso, backticks are absent from some (many?) common non-qwerty keyboards (French azerty, for example), making them even more arcane / un-discoverable.
- elros 10y agoI for one would make no design decisions at all taking French AZERTY as a consideration. As a Frenchman I feel I can say it's the world's most badly designed keyboard that's used in a major language. I would truly like to know its origins and how it got so bad, cause I have no idea. Only two of my main gripes: How come there's a whole key dedicated to superscript 2 and superscript 3? How many times a year does one use the key that's dedicated to the Greek letter Mu and the £ sign? If we're lacking a key for `, howbout we change the ù key into it, given ù is used only in a single word in the whole language?
- leshow 10y agoI've been waiting for 0.18 in anticipation because I had heard we might get server rendering. Instead a bunch of language and syntax that I enjoyed was removed from the language, but I get better bug reports? The export button is broken unless I click "resume" which I find pretty odd. I have to say I'm really disappointed, every release they just remove language features.
- ORioN63 10y agoI was sad to see record fields not being addable anymore. It made for a good typeclass replacement, with no extra baggage.
- zalmoxes 10y agoThat's been gone for a while.
- worldsayshi 10y agoPerhaps it's a cleanup-run before adding new stuff. Removing need for arcane syntax seems like it could simplify the compilation pipeline.
- leshow 10y agoThe syntax was hardly 'arcane', and I doubt it was necessary to remove these features for the purpose of streamlining the compiler, that sounds a bit ridiculous. In fact you could argue that throwing an error on functions' is actually doing more work. That really is a style thing and something best left to a linter or the like. Evan hasn't mentioned anywhere that he's been removing features for the last year or so just to give us some big features later. If he has said that I would love to see it.
- jmite 10y agoRemoving them wasn't necessary, but it's better. Elm isn't 1.0 yet, so "does this make the language better" is the metric for feature addition or deletion.
- gladimdim 10y agoAt work we developed internal tool in Elm + elm-mdl for listening to specific events and notifying developer on their status change. It takes about 5 minutes to understand what is going on in application by just reading Model/Update. One person can refactor almost whole app and be sure he did not break a thing. Most issues we got were in ports (JavaScript). Also the same page is running as Chrome Extension and Firefox Extension. I can say that development performance was 3x than the same developers in JS. Plus you don't have to write unit tests and deal with grunt/gulp/npm packages nonsense. We got only one runtime exception - our state was saved in localStorage and pushed into Elm.embed when page was opened. If this format changes in Elm/localStorage - Elm fails to start. It would be nice to get some promise rejected when you do Elm.embed() and it fails to initialize. But we can write our own Json.decoders and parse state inside application - in such case we can even write data migrators for user data. Next stop for us will be to rewrite some views into Elm and integrate them into huge our JS project.