<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
Scott	B-Application
encoding	I-Application
is	O
a	O
way	O
to	O
represent	O
(	O
recursive	O
)	O
data	O
types	O
in	O
the	O
lambda	B-Application
calculus	I-Application
.	O
</s>
<s>
Church	B-Application
encoding	I-Application
performs	O
a	O
similar	O
function	O
.	O
</s>
<s>
The	O
data	O
and	O
operators	O
form	O
a	O
mathematical	O
structure	O
which	O
is	O
embedded	O
in	O
the	O
lambda	B-Application
calculus	I-Application
.	O
</s>
<s>
Whereas	O
Church	B-Application
encoding	I-Application
starts	O
with	O
representations	O
of	O
the	O
basic	O
data	O
types	O
,	O
and	O
builds	O
up	O
from	O
it	O
,	O
Scott	B-Application
encoding	I-Application
starts	O
from	O
the	O
simplest	O
method	O
to	O
compose	O
algebraic	O
data	O
types	O
.	O
</s>
<s>
Mogensen	B-Application
–	I-Application
Scott	I-Application
encoding	I-Application
extends	O
and	O
slightly	O
modifies	O
Scott	B-Application
encoding	I-Application
by	O
applying	O
the	O
encoding	O
to	O
Metaprogramming	B-Application
.	O
</s>
<s>
This	O
encoding	O
allows	O
the	O
representation	O
of	O
lambda	B-Application
calculus	I-Application
terms	O
,	O
as	O
data	O
,	O
to	O
be	O
operated	O
on	O
by	O
a	O
meta	B-Application
program	I-Application
.	O
</s>
<s>
Torben	O
Mogensen	O
later	O
extended	O
Scott	B-Application
encoding	I-Application
for	O
the	O
encoding	O
of	O
Lambda	O
terms	O
as	O
data	O
.	O
</s>
<s>
Lambda	B-Application
calculus	I-Application
allows	O
data	O
to	O
be	O
stored	O
as	O
parameters	O
to	O
a	O
function	O
that	O
does	O
not	O
yet	O
have	O
all	O
the	O
parameters	O
required	O
for	O
application	O
.	O
</s>
<s>
c	O
may	O
represent	O
a	O
constructor	O
for	O
an	O
algebraic	O
data	O
type	O
in	O
functional	O
languages	O
such	O
as	O
Haskell	B-Language
.	O
</s>
<s>
Mogensen	O
extends	O
Scott	B-Application
encoding	I-Application
to	O
encode	O
any	O
untyped	O
lambda	O
term	O
as	O
data	O
.	O
</s>
<s>
This	O
allows	O
a	O
lambda	O
term	O
to	O
be	O
represented	O
as	O
data	O
,	O
within	O
a	O
Lambda	B-Application
calculus	I-Application
meta	B-Application
program	I-Application
.	O
</s>
<s>
The	O
"	O
lambda	O
term	O
"	O
is	O
represented	O
as	O
a	O
tagged	B-Language
union	I-Language
with	O
three	O
cases	O
:	O
</s>
<s>
The	O
Scott	B-Application
encoding	I-Application
coincides	O
with	O
the	O
Church	B-Application
encoding	I-Application
for	O
booleans	O
.	O
</s>
<s>
compare	O
this	O
to	O
the	O
Mogensen	O
Scott	B-Application
encoding	I-Application
,	O
</s>
<s>
With	O
this	O
generalization	O
,	O
the	O
Scott	O
and	O
Church	B-Application
encodings	I-Application
coincide	O
on	O
all	O
enumerated	O
datatypes	O
(	O
such	O
as	O
the	O
boolean	O
datatype	O
)	O
because	O
each	O
constructor	O
is	O
a	O
constant	O
(	O
no	O
parameters	O
)	O
.	O
</s>
<s>
Concerning	O
the	O
practicality	O
of	O
using	O
either	O
the	O
Church	O
or	O
Scott	B-Application
encoding	I-Application
for	O
programming	O
,	O
there	O
is	O
a	O
symmetric	O
trade-off	O
:	O
Church-encoded	O
numerals	O
support	O
a	O
constant-time	O
addition	O
operation	O
and	O
have	O
no	O
better	O
than	O
a	O
linear-time	O
predecessor	O
operation	O
;	O
Scott-encoded	O
numerals	O
support	O
a	O
constant-time	O
predecessor	O
operation	O
and	O
have	O
no	O
better	O
than	O
a	O
linear-time	O
addition	O
operation	O
.	O
</s>
<s>
The	O
type	O
of	O
the	O
Scott	B-Application
encoding	I-Application
of	O
the	O
natural	O
numbers	O
is	O
the	O
positive	O
recursive	O
type	O
:	O
</s>
<s>
Combining	O
these	O
twos	O
fact	O
yields	O
the	O
System	O
F	O
type	O
of	O
the	O
Scott	B-Application
encoding	I-Application
:	O
</s>
<s>
This	O
can	O
be	O
contrasted	O
with	O
the	O
type	O
of	O
the	O
Church	B-Application
encoding	I-Application
:	O
</s>
<s>
The	O
Church	B-Application
encoding	I-Application
is	O
a	O
second-order	O
type	O
,	O
but	O
the	O
Scott	B-Application
encoding	I-Application
is	O
fourth-order	O
!	O
</s>
