3 ms·
You can blow up the runtime with integer division by zero, however. λ 1 `quot` 0 *** Exception: divide by zero With `1/0`, it uses `Double` because `(
by michaelochurch 11y ago
You can blow up the runtime with integer division by zero, however.
λ 1 `quot` 0
*** Exception: divide by zero
With `1/0`, it uses `Double` because `(/)` requires a Fractional type.
Also, partial functions like `head` or `fromJust` can burn you:
λ head []
*** Exception: Prelude.head: empty list
The latter is a legacy behavior that is generally considered undesirable. The former is more debatable; some would say that you should avoid integer division by an unknown value as much as possible.
In Haskell, exceptions in non-IO code (other than deliberate hard crashes) are generally considered a wart to be avoided and mitigated as much as possible (because they interfere with functional programming).