5 ms·
This inspired me to look up the Elm docs, and came across this gem: view model = div [] [ button [ onClick Decrement ] [ text "-" ] , div []
by i_feel_great 8y ago
This inspired me to look up the Elm docs, and came across this gem:
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (String.fromInt model) ]
, button [ onClick Increment ] [ text "+" ]
]
The html elements themselves are Elm functions. Code looks like data. Nice. Now considering Elm to be potentially useful tool to know.
- grenadier21 8y agoThat's how literally every VDOM-based framework looks, including React. Elm isn't special in this regard. It is special in many other regards, however, and I appreciate it for that. It's also interesting as one of the few languages that have parametric polymorphism but no ad-hoc polymorphism, which leads to some interesting designs. I don't like how only the BDFL is allowed to do certain things, like create new operators in external libraries, but overall, it's a very pleasant experience.
- cttet 8y ago"one of the few languages that have parametric polymorphism but no ad-hoc polymorphism" I wonder what others are? Would like to try them.
- Athas 8y agoOCaml and Standard ML are two others, and I'd say OCaml is established enough that Elm is not really breaching new ground here. The main difference is that OCaml has other features you tend to use instead, particularly the module system.
- ikfmpwdsoz 8y agoOCaml is a very fun language in my experience. Apparently they were going to add ad-hoc polymorphism in the form of modular implicits, but I have no idea what happened to that.
- logicchains 8y agoIt's due around the time OCaml multicore support and Half Life 3 are released.
- rs86 8y agoCan't the module system be used for ad hoc polymorphism?
- lalaithion 8y ago"I don't like how only the BDFL is allowed to do certain things, like create new operators in external libraries" Isn't this true for like, 95% of languages? Yes, Elm breaks from it's Haskell heritage in this regard, but this is a very common lack of feature.
- grenadier21 8y agoFair enough, but my main problem with it was that it existed, and then they removed it, which was very sad.
- bschwindHN 8y agoIf you like that, you might be interested in ClojureScript's reagent: https://reagent-project.github.io/ https://reagent-project.github.io/ And check out re-frame as well, which adds on tools for handling data flow and many other things: https://github.com/Day8/re-frame https://github.com/Day8/re-frame
- vga805 8y agore-frame is beautiful. the real world implementation in re-frame up on https://github.com/gothinkster/realworld https://github.com/gothinkster/realworld has excellent comments and is a great way to learn it after the docs
- fxfan 8y agoThis is actually cool. Scala.js + scalatags has this looking like this: ``` val model = div( button( onClick := decrement )( "-" ), // decrement is typechecked as being a function of event div( float := float.letf )( model.toInt ) //left float is typechecked and hence the misspelling is caught at compile time so big changes can be made with confidence ) ```
- cttet 8y agoThis was also the thing that attracted me to Elm years ago. But at that time Elm doesn't have a CSS module yet. Now with Elm-UI, it is like my dream HTML/CSS replacement. However that was all for static UI though. Writing Elm app is still a pain if you are not a Javascript expert. Elm's implementation of the web API is minimal and the progress is extremely slow. In addition, most function that's in libraries in Javascript's ecosystem can not be directly used as you have to write Ports, which requires a lot of Javascript experience.
- hellofunk 8y agoElm-UI is in a questionable state. Their github page originally said it was no longer maintained. Now they acknowledge that they are struggling to update to the latest version of Elm which caused many syntax breakages.
- korla 8y agoIt looks like it is no longer maintained: https://github.com/gdotdesign/elm-ui/issues/100 https://github.com/gdotdesign/elm-ui/issues/100
- nhanb 8y agocttet probably meant this: https://github.com/mdgriffith/elm-ui https://github.com/mdgriffith/elm-ui
- cttet 8y agoAs nhanb mentioned I meant https://github.com/mdgriffith/elm-ui https://github.com/mdgriffith/elm-ui. There is a great talk about it: https://www.youtube.com/watch?v=Ie-gqwSHQr0 https://www.youtube.com/watch?v=Ie-gqwSHQr0
- dom96 8y agoIf you're interested in this then you might like how Nim approaches this with its React-like framework Karax. No square or other brackets, just indentation defines the structure and it's beautiful. The only oddity is that 'div' has to be written as 'tdiv'. Here is an example from the Nim forum's frontend code: https://github.com/nim-lang/nimforum/blob/master/src/frontend/error.nim#L15 https://github.com/nim-lang/nimforum/blob/master/src/fronten...
- bgorman 8y agoIt might be worth looking at the Reagent framework for Clojurescript.