×
Language:

1Introduction
If
IntroductiontoFunctionalProgramming
[1]orDavie's
GentleIntroduction
1

2
2VALUES,TYPES,ANDOTHERGOODIES
typeful
2Values,Types,andOtherGoodies
expressions
(syntacticterms)toyield
values
type.
(Intuitively,wecanthinkoftypesassetsofvalues.)Examplesofexpressionsincludeatomicvaluessuchastheinteger5,thecharacter'a',andthefunction
\x
->
x+1,
aswellasstructuredvaluessuchasthelist
[1,2,3]
andthepair
('b',4).
Justasexpressionsdenotevalues,typeexpressionsaresyntactictermsthatdenotetypevalues(orjust
types).
Examplesoftypeexpressionsincludetheatomictypes
Integer
(infinite-precisionintegers),
Char
(characters),
Integer->Integer
(functionsmapping
Integer
to
Integer),
aswellasthestructuredtypes
[Integer]
(homogeneouslistsofintegers)and
(Char,Integer)
not
first-class.Typesinasensedescribevalues,andtheassociationofavaluewithitstypeiscalleda
typing.
Usingtheexamplesofvaluesandtypesabove,wewritetypingsasfollows:
5
IntegerCharInteger->Integer[Integer](Char,Integer)
'a'
inc
[1,2,3]
('b',4)
lCoined
by
LucaCardelli.

2.1PolymorphicTypes
3
equations.
Forexample,thefunction
inc
canbedefinedbythesingleequation:
incn
=
n+1
Anequationisanexampleofa
declaration.
Anotherkindofdeclarationisa
typesignaturedecla-ration
(§4.4.1),withwhichwecandeclareanexplicittypingfor
inc:inc::Integer-)Integer
el
evaluates,or"re-duces,"toanotherexpressionorvalue
e2,
wewillwrite:Forexample,notethat:
inc(inc
3)
5
typesafe;
'a'+'b'
infers
thecorrecttypesforus.Nevertheless,judiciousplacementoftypesignaturessuchasthatwegavefor
inc
Integer
and
Char,
butnotidentifiersthatdenotevalues,suchas
inc.
2.1PolymorphicTypes
polymorphic
types-typesthatareuniversallyquantifiedinsomewayoveralltypes.Polymorphictypeexpressionsessentiallydescribefamiliesoftypes.Forexample,
(Va)[a]
isthefamilyoftypesconsistingof,foreverytype
a,
thetypeoflistsof
a.
Listsof
2Withafewexceptionstobedescribedlater.
Search History:
Searching...
Result 00 of 00
00 results for result for
• p.
• Notes