Previous Next Home
If a Function is well defined on all possible arguments, then it is called total function, if it is not well defined for all possible arguments, then it is called partial function. There are several partial functions defined in Haskell standard library.
a. head, tail: undefined for empty lists
b. (!!) : undefined if the index is at least as big as the list length
c. div : undefined if the divisor is zero
Prelude> head 
*** Exception: Prelude.head: empty list
Prelude> tail 
*** Exception: Prelude.tail: empty list
Prelude> 10 `div` 0
*** Exception: divide by zero
Always avoid of defining partial functions in your code.
Following post explains some guide lines to avoid partial functions.