News for hackers. Stuff that matters.
Re:Elm 0.19.1 by toastal on Monday October 21, 2019 @12:55PM (#21314477)
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.

Re:Elm 0.19.1 by sunseb on Monday October 21, 2019 @01:10PM (#21314675)
Ok let's see. Please can you convert this Vue code into Elm code?

https://pastebin.com/trFAuJ7T

Good luck!

Re:Elm 0.19.1 by RussianCow on Monday October 21, 2019 @01:49PM (#21315130)
You couldn't have picked an easier example!

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.

Re:Elm 0.19.1 by lalaithion on Monday October 21, 2019 @01:47PM (#21315111)

    showUsers : [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],
      ]
Re:Elm 0.19.1 by hombre_fatal on Monday October 21, 2019 @01:57PM (#21315223)
The 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?

Re:Elm 0.19.1 by KurtMueller on Monday October 21, 2019 @02:31PM (#21315603)
It was presented to him as a puzzle and he solved the puzzle.

How far do you think he got in Elm?

Re:Elm 0.19.1 by MichaelGlass on Monday October 21, 2019 @01:22PM (#21314817)
Re:Elm 0.19.1 by subsaharancoder on Wednesday October 23, 2019 @02:46PM (#21337571)
Even easier in Clojurescript using 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])])
Re:Elm 0.19.1 by nilkn on Monday October 21, 2019 @04:07PM (#21316696)
As 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.
Re:Elm 0.19.1 by Libbum on Monday October 21, 2019 @01:56PM (#21315208)
An ellie app to play around with: https://ellie-app.com/6YQNRR4MmmZa1