Total Functional Programming

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

Total Functional Programming is pure functional programming with a guarantee that no expression will undefined at run time.

Some operations have an undefined result, for example:

  • division is undefined with a zero denominator
  • an empty list undefined for getting its first element.
  • an array undefined for negative indices or indices beyond its length
  • searching for a negative number in an infinite list of positive numbers will never return

There are a surprising number of operations one can perform in a piece of code that are actually partial.

In most popular functional programming systems today, it is possible to have a run time error when you divide by zero or get the head of an empty list, or a program that runs forever if you have endless recursion.

Total functional programming eliminates this possibility.

The benefit of total functional programming is that eliminating errors and non-termination can greatly simplify program analysis and optimization, for both humans and programs.

8 later thoughts