Total Functional Programming

9 thoughts
last posted July 21, 2014, 7:01 a.m.

8 earlier thoughts

0

Many many functions are partial

One of the thoughts that might come up in the study of total functional programming is that total functions are in fact the normal state of functions and partial functions are the exception.

However, I am thinking this is not really the case. Many arithmetic functions only accept numbers, for example. Division by zero is undefined, making division a partial function.

Here's another perspective: functions are very often partial functions. However, if with static checking we can prove that no invocation of a function is undefined, we can treat the functions "as if" they are total. This is what is actually meant by "total functional programming."

When someone says a function is total, generally they really mean that the particular system they are using is able to enforce the domain of the function prior to running it.

The only functions that are total "as written" are the ones that can accept any object, such as the identity function or a constructor for a general data structure (like a list).