Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Note that bottom is a theoretical concept. If you actually evaluate (1/0) in the haskell interpreter, you get an error message

   *** Exception: Ratio.%: zero denominator
Similarly, if you run an infinite loop in the interpreter, it just loops forever. (Well, in certain special cases it can figure that out and throw an exception). The implementation never creates an actual "bottom" value that has to be handled by e.g. arithmetic operators.

The issue of bottom comes up when you try to define precisely what the meaning of a program is (in the jargon, when you give a denotational semantic). It is clear that the expression (1+1) should "mean" 2, but what is the meaning of an infinite loop? Answer: a special "error value" which we call bottom.

You may wonder why most traditional mathematics doesn't make a fuss about bottom values, and just get away with saying "this is a partial function". This is because most everyday mathematical functions are defined by e.g. simple structural recursion, so issues of termination are seldom very complicated. Once you have general recursion, you need to be more careful.



Not exactly. There's multiple types to divide by multiple kinds of zero, and multiple ways to accomplish it. Remember they're Num, they're not integers

http://stackoverflow.com/questions/9354016/division-by-zero-...

http://www.reddit.com/r/haskell/comments/m7agm/why_doesnt_ha...


Thank you, that cleared things up.

Does Haskell allow you to assert that a function (like, say, the Sieves of Eratosthenes algorithm) does terminate, so that it may use that info to make additional simplifications?


That's a good question that i had previously noted for followup, but I never followed up.

slide 50: how does agda check termination.

http://www.seas.upenn.edu/~sweirich/ssgip/main.pdf

http://research.microsoft.com/en-us/news/features/terminator...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: