5 ms·
HAML and Pug/Jade got popular precisely because HTML/XML is harder to read and easy to make mistakes with all the closing delimiters you need. Making HTML a fun
by toastal 7y ago
HAML and Pug/Jade got popular precisely because HTML/XML is harder to read and easy to make mistakes with all the closing delimiters you need. Making HTML a function with two arguments for virtual DOM is simpler than needing to make an XML parser with special rules ala JSX where people constantly get hung up on className, etc., which compiles to this same binary functions you use in Elm is API.
Pure functions are definitely a selling point. Random number generation needs to be in an isolated part of your app unless it's a toy. Because it deals with IO much like reading from disk, it should have a "hard"-ness to it.
- deleted 7y ago[deleted]
- sunseb 7y agoOk let's see. Please can you convert this Vue code into Elm code? https://pastebin.com/trFAuJ7T https://pastebin.com/trFAuJ7T Good luck!
- MichaelGlass 7y agohttps://mbylstra.github.io/html-to-elm/ https://mbylstra.github.io/html-to-elm/ <3
- lalaithion 7y agoshowUsers : [User] -> Html msg showUsers users = div [id "my-component"] [ul [] (map showUser users)] showUser : User -> Html msg showUser user = li [] [ span [class "firstName"] [text user.firstName], br [] [], span [class "lastName"] [text user.lastName], ]
- RussianCow 7y agoYou couldn't have picked an easier example! https://pastebin.com/QQARqeB9 https://pastebin.com/QQARqeB9 FWIW, I wrote this without having previous Elm experience—the compiler's error messages are so good that it was mostly trial and error until it worked. To your point: I think using language primitives for defining views instead of HTML templating is an advantage for Elm because you can write them using only the Elm language itself, without having to learn yet another syntax. Combined with the excellent compiler error messages, it makes writing views easier and less error prone than writing HTML templates.
- Libbum 7y agoAn ellie app to play around with: https://ellie-app.com/6YQNRR4MmmZa1 https://ellie-app.com/6YQNRR4MmmZa1
- hombre_fatal 7y agoThe fact that you think this is some sort of puzzle makes me question how far you actually got with Elm at all. What's even the "good luck!" part for? Good luck knowing about List.map?
- KurtMueller 7y agoIt was presented to him as a puzzle and he solved the puzzle. How far do you think he got in Elm?
- nilkn 7y agoAs others have shown, Elm is actually super good at stuff like this because you can just write resuable pure Elm functions using functional primitives like map and filter.
- subsaharancoder 7y agoEven easier in Clojurescript using Hiccup https://github.com/weavejester/hiccup https://github.com/weavejester/hiccup to render HTML: (def users [{:firstname "john", :lastname "snow"} {:firstname "Peter", :lastname "drucker"}]) (defn my-view [] [:ul (for [{:keys [firstname lastname]} users] [:li firstname " " lastname])])