4 ms·
This is cool, although the title reminded me of one of my favorite parts of Elm[0]...I've effectively said goodbye to “undefined is not a function” because I've
by rtfeldman 12y ago
This is cool, although the title reminded me of one of my favorite parts of Elm[0]...I've effectively said goodbye to “undefined is not a function” because I've said goodbye to runtime exceptions in general.
More specifically, I have yet to write Elm code that compiles and throws a runtime exception. I sure don't miss seeing "undefined is not a function!"
A top-shelf compiler is a hell of a drug. :)
[0] http://elm-lang.org http://elm-lang.org
- millstone 12y agoHow does Elm handle browser differences? For example, window.clipboardData.setData is only defined in IE, so what happens if I call it unconditionally from Elm, and am using Firefox?
- rtfeldman 12y agoDepends on what you're doing. In some cases Elm.Native will take care of browser differences. In general, Elm's replacement for the concept of undefined is Maybe, and the compiler will tell you if you forgot to handle something properly: http://elm-lang.org/edit/examples/Functional/Maybe.elm http://elm-lang.org/edit/examples/Functional/Maybe.elm
- millstone 12y agoAfter some research, it looks like my answer is that I can't call it unconditionally from Elm. Elm doesn't provide an easy way to access arbitrary JavaScript properties, and doesn't attempt to expose all of the functionality of the browser, but instead provides its own API.