2 ms·
I don’t think the “in type theory” restriction is correct. This choice works fine when using type theory in theorem provers, but would be unacceptable if we di
by Someone 6y ago
I don’t think the “in type theory” restriction is correct.
This choice works fine when using type theory in theorem provers, but would be unacceptable if we did it in programming languages that use type theory (or would that be called “type practice” ;-)?)
In Haskell, for example, 1/0 returns Infinity.
- Sniffnoy 6y agoThat's not exactly right... in Haskell, 1/0 has type Fractional a => a. So, it could be any fractional type. If 1/0 occurs in a context where it'll be interpreted as a floating-point number, you'll get Infinity, yes, as per how standard floating-point works. In other contexts though you may get an error. E.g., if you import Data.Ratio and do 1/0 :: Rational, you'll get an error.
- dddbbb 6y agoThe type signature of division in Haskell merely requires that it takes two fractional `a`s and returns another `a`. 1 / 0 :: Double evaluates to Infinity. 1 / 0 :: Rational throws a runtime exception. A division by zero producing zero would be perfectly sensible in Haskell, and perhaps even desired if you are totally averse to runtime errors. The Pony language infamously does this.
- curryhoward 6y agoIn academia, "type theory" almost always means dependent type theory, such as Martin-Löf type theory or homotopy type theory. Type theory is used in most theorem provers as a foundation for mathematics. The title of this blog post is using the term in a standard way. Programming languages such as Haskell and Java are not based on type theory. They have type systems. Haskell's type system is much closer to type theory than that of Java, but it's still quite crippled compared to what type theorists study. It is of course possible to define things in type theory such that 1/0 = Infinity or something else, but that is not the norm.