<s>
Total	B-Application
functional	I-Application
programming	I-Application
(	O
also	O
known	O
as	O
strong	B-Application
functional	I-Application
programming	I-Application
,	O
to	O
be	O
contrasted	O
with	O
ordinary	O
,	O
or	O
weak	O
functional	B-Language
programming	I-Language
)	O
is	O
a	O
programming	B-General_Concept
paradigm	O
that	O
restricts	O
the	O
range	O
of	O
programs	O
to	O
those	O
that	O
are	O
provably	O
terminating	O
.	O
</s>
<s>
A	O
restricted	O
form	O
of	O
recursion	O
,	O
which	O
operates	O
only	O
upon	O
'	O
reduced	O
 '	O
forms	O
of	O
its	O
arguments	O
,	O
such	O
as	O
Walther	B-Algorithm
recursion	I-Algorithm
,	O
substructural	O
recursion	O
,	O
or	O
"	O
strongly	O
normalizing	O
"	O
as	O
proven	O
by	O
abstract	O
interpretation	O
of	O
code	O
.	O
</s>
<s>
Every	O
function	O
must	O
be	O
a	O
total	O
(	O
as	O
opposed	O
to	O
partial	B-Algorithm
)	O
function	O
.	O
</s>
<s>
There	O
are	O
several	O
possible	O
ways	O
to	O
extend	O
commonly	O
used	O
partial	B-Algorithm
functions	I-Algorithm
such	O
as	O
division	O
to	O
be	O
total	O
:	O
choosing	O
an	O
arbitrary	O
result	O
for	O
inputs	O
on	O
which	O
the	O
function	O
is	O
normally	O
undefined	O
(	O
such	O
as	O
for	O
division	O
)	O
;	O
adding	O
another	O
argument	O
to	O
specify	O
the	O
result	O
for	O
those	O
inputs	O
;	O
or	O
excluding	O
them	O
by	O
use	O
of	O
type	O
system	O
features	O
such	O
as	O
refinement	O
types	O
.	O
</s>
<s>
These	O
restrictions	O
mean	O
that	O
total	B-Application
functional	I-Application
programming	I-Application
is	O
not	O
Turing-complete	O
.	O
</s>
<s>
For	O
example	O
,	O
any	O
algorithm	O
for	O
which	O
an	O
asymptotic	O
upper	O
bound	O
can	O
be	O
calculated	O
(	O
by	O
a	O
program	O
that	O
itself	O
only	O
uses	O
Walther	B-Algorithm
recursion	I-Algorithm
)	O
can	O
be	O
trivially	O
transformed	O
into	O
a	O
provably-terminating	O
function	O
by	O
using	O
the	O
upper	O
bound	O
as	O
an	O
extra	O
argument	O
decremented	O
on	O
each	O
iteration	O
or	O
recursion	O
.	O
</s>
<s>
For	O
example	O
,	O
quicksort	B-Algorithm
is	O
not	O
trivially	O
shown	O
to	O
be	O
substructural	O
recursive	O
,	O
but	O
it	O
only	O
recurs	O
to	O
a	O
maximum	O
depth	O
of	O
the	O
length	O
of	O
the	O
vector	O
(	O
worst-case	O
time	O
complexity	O
O(n2 )	O
)	O
.	O
</s>
<s>
A	O
quicksort	B-Algorithm
implementation	O
on	O
lists	O
(	O
which	O
would	O
be	O
rejected	O
by	O
a	O
substructural	O
recursive	O
checker	O
)	O
is	O
,	O
using	O
Haskell	O
:	O
</s>
<s>
Another	O
outcome	O
of	O
total	B-Application
functional	I-Application
programming	I-Application
is	O
that	O
both	O
strict	O
evaluation	O
and	O
lazy	O
evaluation	O
result	O
in	O
the	O
same	O
behaviour	O
,	O
in	O
principle	O
;	O
however	O
,	O
one	O
or	O
the	O
other	O
may	O
still	O
be	O
preferable	O
(	O
or	O
even	O
required	O
)	O
for	O
performance	O
reasons	O
.	O
</s>
<s>
In	O
total	B-Application
functional	I-Application
programming	I-Application
,	O
a	O
distinction	O
is	O
made	O
between	O
data	O
and	O
codata	O
—	O
the	O
former	O
is	O
finitary	O
,	O
while	O
the	O
latter	O
is	O
potentially	O
infinite	O
.	O
</s>
<s>
Such	O
potentially	O
infinite	O
data	O
structures	O
are	O
used	O
for	O
applications	O
such	O
as	O
I/O	B-General_Concept
.	O
</s>
<s>
Using	O
codata	O
entails	O
the	O
usage	O
of	O
such	O
operations	O
as	O
corecursion	B-Application
.	O
</s>
<s>
However	O
,	O
it	O
is	O
possible	O
to	O
do	O
I/O	B-General_Concept
in	O
a	O
total	B-Application
functional	I-Application
programming	I-Application
language	O
(	O
with	O
dependent	O
types	O
)	O
also	O
without	O
codata	O
.	O
</s>
<s>
Both	O
Epigram	B-Language
and	O
Charity	O
could	O
be	O
considered	O
total	B-Application
functional	I-Application
programming	I-Application
languages	O
,	O
even	O
though	O
they	O
do	O
not	O
work	O
in	O
the	O
way	O
Turner	O
specifies	O
in	O
his	O
paper	O
.	O
</s>
<s>
So	O
could	O
programming	B-General_Concept
directly	O
in	O
plain	O
System	O
F	O
,	O
in	O
Martin-Löf	O
type	O
theory	O
or	O
the	O
Calculus	B-Application
of	I-Application
Constructions	I-Application
.	O
</s>
