Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 7
    -1 for "leverage"! Commented Oct 18, 2010 at 19:17
  • 9
    But surely lots of common programming constructs allow for nonsensical code, no? Division by zero is (arguably) nonsensical, but we still allow division, and hope the programmer remembers to check that the divisor is non-zero (or handle the exception). Commented Oct 18, 2010 at 20:14
  • 3
    I'm not certain what you mean by "from scratch", but Maybe isn't built into the core language, its definition just happens to be in the standard prelude: data Maybe t = Nothing | Just t. Commented Oct 18, 2010 at 21:28
  • 4
    @FredOverflow: since the prelude is loaded by default, I would consider it "from scratch", that Haskell has a astonishing enough type system to allow this (and other) niceties to be defined with the general rules of the language is just a bonus :) Commented Oct 20, 2010 at 15:00
  • 2
    @TimGoodman While division by zero may not be the best example for all numeric value types (IEEE 754 defines a result for division by zero), in cases where it would throw an exception, instead of having values of type T divided by other values of type T, you would limit the operation to values of type T divided by values of type NonZero<T>. Commented Feb 11, 2016 at 16:29