Question: but why not implement the custom elements in Elm then?
in theory, Elm could provide an interface to a custom element like element without needing support for custom elements from the browser.

Asked By

pdamoc

Asked At

2018-05-14 15:39:08

Found 15 possible answers.

User

Answered At

Possible Answer

utkarshkukreti

2018-05-14 15:42:56

Writing complex web components also means that porting it to a different compilation target in the future (when Elm supports more targets) would be harder. If Elm could provide some support for being able to define something like web components, we could reduce the amount of JS code in our apps.

pdamoc

2018-05-14 15:50:27

@utkarshkukreti I don’t think it is feasible in any near-future for Elm to support a different compilation target at the level of UI. The amount of complexity html nodes + CSS encompass is astronomical.
In other words, the reimplementation of those primitives would probably dwarf the current implementation of the compiler & core libraries by an order of magnitude.

rtfeldman

2018-05-14 15:55:39

> but why not implement the custom elements in Elm then?
new features always have to justify their need with motivating use cases; there's no justification needed for *not* adding features!
Elm prioritizes simplicity; the answer to any "Why not do ______?" question is by default "let's see if we can get away with not doing it," not "let's see how much we can add to the language" :smile:

@utkarshkukreti I’m not arguing for allowing Native/Kernel code. The functionality of a custom element could be provided by a function that takes a record similar to the one program takes and returns a Html msg. Nothing needs to be added to the language.

utkarshkukreti

2018-05-14 16:02:15

I agree with you. It would be interesting to explore this and see how it affects the readability of medium to complex apps.

rtfeldman

2018-05-14 16:02:48

you can already see that - look at React apps
(from a state management perspective I mean)
it's the same design as React :slightly_smiling_face:

utkarshkukreti

2018-05-14 16:03:31

But JS is not the same as Elm. We don't have such a good type system to work with.

rtfeldman

2018-05-14 16:06:46

sure, but in terms of readability of medium to complex apps, it'd presumably be roughly the same structure
(if there exists a community of UI developers in which state management is not debated, I'm not aware of it)
higher order components vs render props vs etc etc :wink:
or structures, I suppose

pdamoc

2018-05-14 16:08:24

@utkarshkukreti there are unintended consequences to each choice made and allowing what I was describing above is not something trivial or something that cannot be abused.

tony_bradley

2018-05-14 16:58:41

anyone experienced with material design guidelines here?

supermario

2018-05-14 18:15:07

Folks in #elm-mdl might know some stuff :slightly_smiling_face:

zinahe

2018-05-14 22:22:09

The true meaning of log : String -> a -> a just occurred to me. I spent the last 15 mins marveling at it's simplicity and elegance; I just couldn't keep it inside me, but there was no one around to share. So I turned to Slack. (This may sound trivial to y'all FP gurus, it blew my noob's mind away)