5 ms·
Ok let's see. Please can you convert this Vue code into Elm code? https://pastebin.com/trFAuJ7T https://pastebin.com/trFAuJ7T Good luck!
by sunseb 7y ago
Ok 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])])