4 ms·
I think that's a fine assertion to make, because Haskell functions can die at runtime because of pattern match failure or an explicit evaluation of "bottom" (un
by jrockway 10y ago
I think that's a fine assertion to make, because Haskell functions can die at runtime because of pattern match failure or an explicit evaluation of "bottom" (undefined).
Prelude> undefined
*** Exception: Prelude.undefined
Prelude> let x 2 = 4 in x 1
*** Exception: <interactive>:7:5-11: Non-exhaustive patterns in function x
Neither of these behaviors is indicated in the type definition:
Prelude> :t undefined
undefined :: t
Prelude> :t let x 2 = 4 in x
let x 2 = 4 in x :: (Eq a, Num a, Num a1) => a -> a1
I was promised a -> a but got a runtime exception instead.
- tiagobraw 10y agoisn't bottom part of any data type, including a?
- jrockway 10y agoIt is, yes, but people often proclaim "haskell has solved the 'null' problem", and it hasn't because bottom is the exact same thing as null.
- tome 10y ago> bottom is the exact same thing as null No it's not because you can't check for bottom (purely) and thus you can't use it as a flag or sentinel value.
- wyager 10y agoYou can get full pattern match checking via -fwarn-incomplete-patterns. Crashing on bottom is a concession to the fact that crashing is more useful than infinite loops. The semantics of the program exiting are the same as the semantics of the program infinite looping. So I'd say it's as pure as you can get on a finite state computer.
- dllthomas 10y ago> You can get full pattern match checking via -fwarn-incomplete-patterns. Only at definition site, not use site, for both better and worse.