3 ms·
> Again: no way to enumerate the options at compile or runtime so copy paste it is: The author didn't find a built-in function to construct a list of option ta
by wfleming 10y ago
> Again: no way to enumerate the options at compile or runtime so copy paste it is:
The author didn't find a built-in function to construct a list of option tags from a list of strings, so, instead of building their own... they copy pasted all the strings and manually built the option tags one by one. They could have collapsed that into a one-line `map` call.
Elm is young and has a long way to go: it is definitely missing many of the conveniences that a web framework will give you (such as functions for building forms from data). Personally, I miss typeclasses coming from Haskell. But it is a Haskell/ML-influenced language before it is a web framework, so for a while anybody using it should expect to be building more of their own plumbing.
Maybe I'm being presumptuous, but the author's approach seems like the kind of error fairly junior programmers make all the time: "if there's no function to do it for me, it can't be done, I'll copy-paste". That's a teachable moment. It's too bad if trying Elm when they didn't have the experience to build their own plumbing turned them off from that kind of approach: I liked Elm for a side project, and am hoping to try similar approaches like PureScript in the future. Getting the "if it compiles it probably works" experience on the front end is addictive.
- leshow 10y agoHow would you enumerate over a union type? as far as I know there is no way to do that in Elm. Can you show your one line map call youre talking about
- deleted 10y ago[deleted]
- eskimobloood 10y agoI think he means to make a list of all member of the type and then iterate over it. Then you have the options method that get a union type and can render the correct output
- Touche 10y agoThis is mentioned in the article. The author criticizes this because it means they have to keep the type and the list in sync. I think this is a pretty pedantic reason to dismiss a language, personally.
- charlieflowers 10y agoMaybe to _dismiss_ a language. But it is a reasonable _criticism_ of the language. I hate those kinds of edge cases between strong and weak typing where the compiler knows something, but you have to express it again. Granted, though, there aren't many languages that can handle that. As far as I can see, it requires compile-time code execution.
- darawk 10y agoIMO that's a pretty good criticism of a language that's supposed to be type-safe, but forces you to break its type safety because its lack of a feature.
- nicops 10y agoAnd it's not like any other language you can choose from for working in the browser is perfect.