Yeah, not that hard to understand, but as the size of the application grow, so seems like the syntax would. I find it hard to imagine staring at so much code with so little value per character/word/syntax as what this seems to have.
It's really hard to see what is what, without really digging into it, and everything is repeated everywhere for maximum explicitness (thanks types?). Why is `Html.Attributes.style` and `HTML.text` repeated so many times when it's just style declaration for one thing and of course a string would be Html.text, what else could it be? It seems so verbose.
But then my benchmark for expressiveness would probably be Clojure (ClojureScript in this case [Reagent]), and it would look like this:
You can also `import Html.Attributes as Attr` and do `Attr.style "foo" "bar"`, or `import Html.Attributes exposing (style)` and do `style "foo" "bar"`.
Or, you know, since it's a composable ML-style functional language, you can grab a package like elm-css[0] and do:
...which gives you full compile-time type-checked styles with a no-crash guarantee. Can Clojure Spec give you the same in your example above?
Incidentally, it's also less noisy than the equivalent block of Clojure code. Elm isn't perfect, and definitely gets verbose at points, but if you're going to criticize, make an informed comparison.
> Why is `Html.Attributes.style` and `HTML.text` repeated so many times
Because it is constructor.
Html.text "STRING"
constructs a HTML text element from "STRING".
But because of
import Html exposing (br, button, div, p, text, h3, a)
import Html.Attributes exposing (style, href)
the `HTML` and `Html.Attributes` prefixes are actually not needed and not used in the lower part (in the `view` function).
> what else could it be
For example an attribute like the `id`, or a class name or ...
Yes, Ok, it actually can't be in the second array, the first array is for the attributes and the second one for the child elements.
To be honest, the differences between Clojurescript with Reagent, Elm or PureScript with Halogon / React are minimal for me.
heh, just took a look. I don't, in this case, it's worth it. It's "unminified", but it's certainly not readable or at least not worth reading through for a simple application like this. I understand that this is just the output of the elm compiler along with its standard libraries.
[0] - https://derw-lang.github.io/
[1] - https://derw-lang.github.io/examples/jeopardy/