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.

4
  • 1
    True, but note that Haskell doesn't use this for division by zero. Instead, every Haskell type implicitly has "bottom" as a possible value. This isn't like null pointers in the sense that it's the "value" of an expression that fails to terminate. You can't test for nontermination as a value, of course, but in operational semantics the cases that fail to terminate are part of the meaning of an expression. In Haskell, that "bottom" value also handles additional error-case results such as the error "some message" function being evaluated. Commented Nov 15, 2013 at 16:46
  • Personally, if the effect of aborting the whole program is considered valid, I don't know why pure code can't have the effect of throwing an exception, but that's just me - Haskell doesn't allow pure expressions to throw exceptions. Commented Nov 15, 2013 at 16:49
  • I think this is a good idea because other than throwing an exception, all the proposed options do not communicate to the users that they made a mistake. The basic idea is that the user makes a mistake with the value they gave to the program, so the program should tell the user that they gave wrong input (then the user can think of a way to remedy). Without telling the users about their mistake, any solution feels so odd. Commented Jul 13, 2014 at 5:03
  • I think this is the way to go... The Rust programming language uses it extensively in its standard library. Commented Jul 13, 2014 at 15:13