3 ms·
What is meant by "zero runtime errors?" An example of a "runtime error" is the head of an empty list; how does Grain handle this?
by millstone 8y ago
What is meant by "zero runtime errors?" An example of a
"runtime error" is the head of an empty list; how does Grain handle this?
- frou_dh 8y agoPresumably the head function returns a value of type Optional/Maybe, that needs to be pattern matched against statically.
- masklinn 8y agoGrain seems way unfinished and the stdlib does not seem to have any such function[0], so here's how Elm handles it instead as it has the same target/ethos of avoiding runtime errors: http://package.elm-lang.org/packages/elm-lang/core/latest/List#head http://package.elm-lang.org/packages/elm-lang/core/latest/Li... [0] it's not very useful either if you have pattern matching on lists, you can just match the list directly.
- marijn 8y agoThe DOM example further down the page, which does no result checking on queries that can absolutely fail to find an element, makes me very skeptical of this claim.