%!PS-Adobe-2.0 %%Creator: dvips, version 5.4 (C) 1986-90 Radical Eye Software %%Title: tutorial.dvi %%Pages: 53 1 %%BoundingBox: 0 0 612 792 %%EndComments %%BeginProcSet: tex.pro /TeXDict 200 dict def TeXDict begin /N /def load def /B{bind def}N /S /exch load def /X{S N}B /TR /translate load N /isls false N /vsize 10 N /@rigin{ isls{[0 1 -1 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale Resolution VResolution vsize neg mul TR}B /@letter{/vsize 10 N}B /@landscape{ /isls true N /vsize -1 N}B /@a4{/vsize 10.6929133858 N}B /@a3{/vsize 15.5531 N }B /@ledger{/vsize 16 N}B /@legal{/vsize 13 N}B /@manualfeed{statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0 0]N /FBB[0 0 0 0 ]N /df{/sf 1 N /fntrx FMat N df-tail}B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0 ]N df-tail}B /df-tail{/nn 8 dict N nn begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo setfont}2 array copy cvx N load 0 nn put /ctr 0 N[ }B /E{pop nn dup definefont setfont}B /ch-image{ch-data dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /ch-width{ch-data dup length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128 ch-data dup length 3 sub get sub}B /ch-yoff{ch-data dup length 2 sub get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B /ctr 0 N /CharBuilder{save 3 1 roll S dup /base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]{ch-image}imagemask restore}B /D{ /cc X dup type /stringtype ne{]}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin 0 0 moveto}B /eop{clear SI restore showpage userdict /eop-hook known{eop-hook}if}B /@start{userdict /start-hook known{start-hook}if /VResolution X /Resolution X 1000 div /DVImag X /IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for}B /p /show load N /RMat[1 0 0 -1 0 0]N /BDot 8 string N /v{/ruley X /rulex X V}B /V{gsave TR -.1 -.1 TR rulex ruley scale 1 1 false RMat{BDot}imagemask grestore}B /a{moveto}B /delta 0 N /tail{ dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{S p tail}B /c{-4 M}B /d{ -3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{3 M}B /k{4 M}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w}B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t {p 4 w}B /w{0 rmoveto}B /x{0 S rmoveto}B /y{3 2 roll p a}B /bos{/SS save N}B /eos{clear SS restore}B end %%EndProcSet %%BeginProcSet: special.pro TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N /vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP false N /BBcalc false N /p 3 def}B /@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{ @scaleunit div /vsc X}B /@hsize{/hs X /CLIP true N}B /@vsize{/vs X /CLIP true N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{10 div /rwi X} B /@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X /BBcalc true N}B /magscale true def end /@MacSetUp{userdict /md known{userdict /md get type /dicttype eq{md begin /letter{}N /note{}N /legal{}N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath clippath mark{transform{ itransform moveto}}{transform{itransform lineto}}{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{ PaintBlack}if}N /txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr 0 get neg sub neg 0 S TR}if} ifelse scaleby96{ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp{pop pop showpage pm restore}N end}if} if}N /normalscale{Resolution 72 div VResolution 72 div neg scale magscale{ DVImag dup scale}if}N /psfts{S 65536 div N}N /startTexFig{/psf$SavedState save N userdict maxlength dict begin /magscale false def normalscale currentpoint TR /psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts /psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR /showpage{}N /erasepage{}N /copypage{}N @MacSetUp}N /doclip{psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2 roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict begin /SpecialSave save N gsave normalscale currentpoint TR @SpecialDefaults}B /@setspecial{CLIP{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto closepath clip}{initclip}ifelse ho vo TR hsc vsc scale ang rotate BBcalc{rwi urx llx sub div dup scale llx neg lly neg TR}if /showpage{}N /erasepage{}N /copypage{}N newpath}B /@endspecial{grestore clear SpecialSave restore end}B /@defspecial{SDict begin}B /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{/SaveX currentpoint /SaveY X N 1 setlinecap newpath}B /st{stroke SaveX SaveY moveto}B /fil{fill SaveX SaveY moveto}B /ellipse{/endangle X /startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}B end %%EndProcSet TeXDict begin 1000 300 300 @start /Fa 3 84 df<00000000C000000001E000000003E000 000003C000000007C00000000F800000001F000000001E000000003E000000007C00000000F800 000000F000000001F000000003E000000007C000000007800000000F800000001F000000003E00 0000003C000000007C00000000F800000001F000000001E000000003E000000007C00000000780 0000000F800000001F000000003E000000003C000000007C00000000F800000001F000000001E0 00000003E000000007C00000000F800000000F000000001F000000003E000000007C0000000078 00000000F800000000F0000000006000000000232E82AB1F>19 D<00000000001800000000003C 0000000000FC0000000001F80000000003F00000000007E0000000001F80000000003F00000000 007E0000000001FC0000000003F00000000007E0000000000FC0000000003F00000000007E0000 000000FC0000000001F80000000007E0000000000FC0000000001F80000000007F0000000000FC 0000000001F80000000003F0000000000FC0000000001F80000000003F00000000007E00000000 01F80000000003F00000000007E0000000001FC0000000003F00000000007E0000000000FC0000 000000F000000000006000000000002E2582A22A>35 D<6000000000F000000000F80000000078 000000007C000000003E000000001F000000000F000000000F8000000007C000000003E0000000 01E000000001F000000000F8000000007C000000003C000000003E000000001F000000000F8000 0000078000000007C000000003E000000001E000000001F000000000F8000000007C000000003C 000000003E000000001F000000000F80000000078000000007C000000003E000000001F0000000 00F000000000F8000000007C000000003E000000001E000000001F000000000F8000000007C000 000003C000000003E000000001E000000000C0232E82AB1F>83 D E /Fb 5 111 df<004000C000C003800D8001800180030003000300030006000600060006000C000C00 0C000C001800FF800A157C9412>49 D<030706000000000000384C4C4C8C181818303262622438 08177D960B>105 D<003000700020000000000000000000000000038004400460046008C000C0 00C000C0018001800180018003000300030003006600E600CC0070000C1D81960B>I<1F000600 0600060006000C000C000C000C001870189819381A30340038003E0033006300631063106310C3 20C1C00D177D9610>I<387044984708460C8C180C180C180C1818301831186118623026303810 0E7D8D14>110 D E /Fc 46 122 df<000FF07F00007FF9FF8000F83FC7C001E07F8FC003E07F 0FC007C07F0FC007C03F078007C01F000007C01F000007C01F000007C01F000007C01F0000FFFF FFF800FFFFFFF80007C01F000007C01F000007C01F000007C01F000007C01F000007C01F000007 C01F000007C01F000007C01F000007C01F000007C01F000007C01F000007C01F000007C01F0000 07C01F000007C01F00003FF8FFF0003FF8FFF0002220809F1F>11 D45 D<387CFEFEFE7C3807077C860F>I<00E00001E0000FE000FFE000F3E00003E00003E0 0003E00003E00003E00003E00003E00003E00003E00003E00003E00003E00003E00003E00003E0 0003E00003E00003E00003E00003E00003E00003E000FFFF80FFFF80111D7C9C1A>49 D<07F0001FFE00383F007C1F80FE0FC0FE0FC0FE0FE0FE07E07C07E03807E0000FE0000FC0000F C0001F80001F00003E0000780000F00000E00001C0000380600700600E00601C00E01FFFC03FFF C07FFFC0FFFFC0FFFFC0131D7D9C1A>I<01FC0007FF000E0F801E0FC03F07E03F07E03F07E03F 07E01E0FC0000FC0000F80001F0001FC0001FC00000F800007C00003E00003F00003F83803F87C 03F8FE03F8FE03F8FE03F0FC03F07807E03C0FC01FFF8003FC00151D7E9C1A>I<0001C00003C0 0007C00007C0000FC0001FC0003BC00073C00063C000C3C00183C00383C00703C00E03C00C03C0 1803C03803C07003C0E003C0FFFFFEFFFFFE0007C00007C00007C00007C00007C00007C000FFFE 00FFFE171D7F9C1A>I<3803803FFF803FFF003FFE003FFC003FF0003F80003000003000003000 0030000033F80037FE003C1F00380F801007C00007C00007E00007E07807E0FC07E0FC07E0FC07 E0FC07C0780FC0600F80381F001FFC0007F000131D7D9C1A>I<387CFEFEFE7C38000000000000 387CFEFEFE7C3807147C930F>58 D<0000E000000000E000000001F000000001F000000001F000 000003F800000003F800000006FC00000006FC0000000EFE0000000C7E0000000C7E000000183F 000000183F000000303F800000301F800000701FC00000600FC00000600FC00000C007E00000FF FFE00001FFFFF000018003F000018003F000030001F800030001F800060001FC00060000FC000E 0000FE00FFE00FFFE0FFE00FFFE0231F7E9E28>65 DI<0007FC 02003FFF0E00FE03DE03F000FE07E0003E0FC0001E1F80001E3F00000E3F00000E7F0000067E00 00067E000006FE000000FE000000FE000000FE000000FE000000FE000000FE0000007E0000007E 0000067F0000063F0000063F00000C1F80000C0FC0001807E0003803F0007000FE01C0003FFF80 0007FC001F1F7D9E26>IIII72 D76 D78 D<001FF80000FFFF0001F81F8007E007E00FC003F01F8001F81F0000F83F0000FC7F0000FE7E00 007E7E00007EFE00007FFE00007FFE00007FFE00007FFE00007FFE00007FFE00007FFE00007FFE 00007F7E00007E7F0000FE7F0000FE3F0000FC3F8001FC1F8001F80FC003F007E007E001F81F80 00FFFF00001FF800201F7D9E27>II<03FC080FFF381E03F838 00F8700078700038F00038F00018F00018F80000FC00007FC0007FFE003FFF801FFFE00FFFF007 FFF000FFF80007F80000FC00007C00003CC0003CC0003CC0003CE00038E00078F80070FE01E0E7 FFC081FF00161F7D9E1D>83 D<7FFFFFFC7FFFFFFC7C07E07C7007E01C6007E00C6007E00CE007 E00EC007E006C007E006C007E006C007E0060007E0000007E0000007E0000007E0000007E00000 07E0000007E0000007E0000007E0000007E0000007E0000007E0000007E0000007E0000007E000 0007E0000007E00003FFFFC003FFFFC01F1E7E9D24>I87 D<07FC001FFF003F0F803F07C03F03E03F03E00C03E00003E000 7FE007FBE01F03E03C03E07C03E0F803E0F803E0F803E0FC05E07E0DE03FF8FE0FE07E17147F93 19>97 DI<01FE0007FF801F0FC03E 0FC03E0FC07C0FC07C0300FC0000FC0000FC0000FC0000FC0000FC00007C00007E00003E00603F 00C01F81C007FF0001FC0013147E9317>I<0007F80007F80000F80000F80000F80000F80000F8 0000F80000F80000F80000F80000F801F8F80FFEF81F83F83E01F87E00F87C00F87C00F8FC00F8 FC00F8FC00F8FC00F8FC00F8FC00F87C00F87C00F87E00F83E01F81F07F80FFEFF03F8FF18207E 9F1D>I<01FE0007FF800F83C01E01E03E00F07C00F07C00F8FC00F8FFFFF8FFFFF8FC0000FC00 00FC00007C00007C00003E00181E00180F807007FFE000FF8015147F9318>I<001F8000FFC001 F3E003E7E003C7E007C7E007C3C007C00007C00007C00007C00007C000FFFC00FFFC0007C00007 C00007C00007C00007C00007C00007C00007C00007C00007C00007C00007C00007C00007C00007 C00007C0003FFC003FFC0013207F9F10>I<01FC3C07FFFE0F079E1E03DE3E03E03E03E03E03E0 3E03E03E03E01E03C00F07800FFF0009FC001800001800001C00001FFF800FFFF007FFF81FFFFC 3C007C70003EF0001EF0001EF0001E78003C78003C3F01F80FFFE001FF00171E7F931A>II<1C003E007F007F007F003E001C000000 00000000000000000000FF00FF001F001F001F001F001F001F001F001F001F001F001F001F001F 001F001F001F00FFE0FFE00B217EA00E>I107 DIII<01FF0007FFC01F83F03E00F83E00F87C007C7C007CFC 007EFC007EFC007EFC007EFC007EFC007E7C007C7C007C3E00F83E00F81F83F007FFC001FF0017 147F931A>II<01F81807FE381F87783F01F83E01F87E00 F87C00F8FC00F8FC00F8FC00F8FC00F8FC00F8FC00F87C00F87E00F87E00F83F01F81F87F80FFE F803F8F80000F80000F80000F80000F80000F80000F80000F80007FF0007FF181D7E931C>II<0FE63FFE701E600EE006E006 F800FFC07FF83FFC1FFE03FE001FC007C007E007F006F81EFFFCC7F010147E9315>I<01800180 018003800380038007800F803F80FFFCFFFC0F800F800F800F800F800F800F800F800F800F800F 860F860F860F860F8607CC03F801F00F1D7F9C14>III120 DI E /Fd 2 111 df<0300038003000000000000000000000000001C002400460046 008C000C0018001800180031003100320032001C0009177F960C>105 D<383C0044C600470200 4602008E06000C06000C06000C0C00180C00180C40181840181880300880300F00120E7F8D15> 110 D E /Fe 20 122 df<03CC0E2E181C381C301C701CE038E038E038E038C072C072C07260F2 61341E180F107C8F14>97 D<7E000E000E000E001C001C001C001C00380038003BC03C30783070 1870187018E038E038E038E038C070C060C0E060C063801E000D1A7C9912>I<01F006080C1818 38301070006000E000E000E000E000E008E010602030C01F000D107C8F12>I<001F8000038000 0380000380000700000700000700000700000E00000E0003CE000E2E00181C00381C00301C0070 1C00E03800E03800E03800E03800C07200C07200C0720060F2006134001E1800111A7C9914>I< 01E006181C08380870087010FFE0E000E000E000E000E0086010602030C01F000D107C8F12>I< 1F80000380000380000380000700000700000700000700000E00000E00000E7C000F86001E0700 1E07001C07001C0700380E00380E00380E00381C00701C80701C80703880703900E01900600E00 111A7E9914>104 D<030706000000000000384C4E8E9C9C1C3838707272E2E4643808197C980C> I<1F8003800380038007000700070007000E000E000E0E0E131C271C431C801F003C003F8039C0 38E070E270E270E270E4E0646038101A7E9912>107 D<3F0707070E0E0E0E1C1C1C1C38383838 70707070E4E4E4E46830081A7D990A>I<307C1E00598663009E0783809E0703809C0703809C07 0380380E0700380E0700380E0700380E0E00701C0E40701C0E40701C1C40701C1C80E0380C8060 1807001A107C8F1F>I<307C005986009E07009E07009C07009C0700380E00380E00380E00381C 00701C80701C80703880703900E01900600E0011107C8F16>I<01F006180C0C180E300E700E60 0EE00EE00EE00CE01CE018E030606030C01F000F107C8F14>I<030F000590C009E0C009C06009 C06009C0600380E00380E00380E00380E00701C00701800703800703000E8E000E78000E00000E 00001C00001C00001C00001C0000FF00001317808F14>I<03C20E2E181C381C301C701CE038E0 38E038E038C070C070C07060F061E01EE000E000E001C001C001C001C01FF00F177C8F12>I<30 F059189E389C189C009C0038003800380038007000700070007000E00060000D107C8F10>I<03 E004300830187018601C001F801FC00FE000E00060E060E06080C041803E000C107D8F10>I<06 000E000E000E000E001C001C00FFC01C0038003800380038007000700070007000E100E100E100 E200640038000A177C960D>I<38064C074E0E8E0E9C0E9C0E1C1C381C381C381C703970397039 3079389A0F0C10107C8F15>I<38184C1C4E1C8E0C9C0C9C0C1C08380838083808701070107020 304018C00F000E107C8F12>I<38064C074E0E8E0E9C0E9C0E1C1C381C381C381C703870387038 307838F00F700070006060E0E1C0C18047003C0010177C8F13>121 D E /Ff 27 122 df<60F0F878181818303060C080050C789614>39 D<00C001C0030006000C001C00 38003000700070006000E000E000E000E000E000E000E000600070007000300038001C000C0006 00030001C000C00A1D7A9914>I<8000C0006000300018001C000E000600070007000300038003 800380038003800380038003000700070006000E001C00180030006000C0008000091D7C9914> I<01C00001C00001C00001C00001C00001C00001C000FFFF80FFFF80FFFF8001C00001C00001C0 0001C00001C00001C00001C00011117F9314>43 D<70F8FCFC7C0C1830E0C0060A798414>I<70 F8F8F8700505798414>46 D<0006000E000E001C001C003800380070007000E000E001C001C003 8003800380070007000E000E001C001C003800380070007000E000E000C0000F1D7E9914>I<70 F8F8F87000000000000070F8F8F8700510798F14>58 D61 D91 D93 D<0818306060C0C0C0F0F87830050C799914>96 D<1FC0007FF000707800201800001C00001C00 07FC001FFC003C1C00701C00E01C00E01C00E01C00707C003FFF800F8F8011107E8F14>I<03F8 0FFC1C1C380870006000E000E000E000E00060007000380E1C1E0FFC03F00F107E8F14>99 D<007E00007E00000E00000E00000E00000E00000E0007CE000FFE001C3E00301E00700E00E00E 00E00E00E00E00E00E00E00E00E00E00700E00301E00383E001FEFC007CFC012177F9614>I<07 E00FF01C38301C700CE00EE00EFFFEFFFEE00060007000380E1C1E0FFC03F00F107E8F14>I<00 7C00FE01CE03840380038003807FFEFFFE03800380038003800380038003800380038003800380 03807FFC7FFC0F177F9614>I<030007800780030000000000000000007F807F80038003800380 038003800380038003800380038003800380FFFCFFFC0E187D9714>105 D108 D110 D<07C01FF03C78701C701CE00EE00EE00EE00EE00EE00E701C783C3C781FF007C00F107E8F14> I<03CE000FFE001C3E00301E00700E00E00E00E00E00E00E00E00E00E00E00E00E00700E00301E 001C3E000FEE0007CE00000E00000E00000E00000E00000E00000E00007FC0007FC012187F8F14 >113 D<0FD83FF86038C038C038F0007F803FF007F8001C6006E006F006F81CFFF8CFE00F107E 8F14>115 D<030007000700070007007FFCFFFC07000700070007000700070007000700070E07 0E070E070C03FC00F00F157F9414>I118 D<7E3F007E3F001E38000E780007700007E00003E00001C00003C00003E0000770000E78000E38 001C1C00FE3F80FE3F8011107F8F14>120 DI E /Fg 56 123 df<000FF000007FFC0001F80E 0003E01F0007C03F000F803F000F803F000F801E000F800C000F8000000F8000000F8000000F80 0000FFFFFF00FFFFFF000F801F000F801F000F801F000F801F000F801F000F801F000F801F000F 801F000F801F000F801F000F801F000F801F000F801F000F801F000F801F000F801F000F801F00 0F801F007FF0FFE07FF0FFE01B237FA21F>12 D<3803807C07C0FE0FE0FF0FF0FF0FF07F07F03B 03B00300300300300700700600600600600C00C01C01C018018070070020020014117EA21D>34 D<387CFEFFFF7F3B03030706060C1C18702008117C8610>44 DI<387CFEFEFE7C3807077C8610>I<0000180000380000380000700000700000E00000E00000E0 0001C00001C0000380000380000380000700000700000700000E00000E00001C00001C00001C00 00380000380000700000700000700000E00000E00001C00001C00001C000038000038000070000 0700000700000E00000E00000E00001C00001C0000380000380000380000700000700000E00000 E00000C0000015317DA41C>I<00180000780001F800FFF800FFF80001F80001F80001F80001F8 0001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F8 0001F80001F80001F80001F80001F80001F80001F80001F8007FFFE07FFFE013207C9F1C>49 D<03FC000FFF003C1FC07007E07C07F0FE03F0FE03F8FE03F8FE01F87C01F83803F80003F80003 F00003F00007E00007C0000F80001F00003E0000380000700000E01801C0180380180700180E00 380FFFF01FFFF03FFFF07FFFF0FFFFF0FFFFF015207D9F1C>I<00FE0007FFC00F07E01E03F03F 03F03F81F83F81F83F81F81F03F81F03F00003F00003E00007C0001F8001FE0001FF000007C000 01F00001F80000FC0000FC3C00FE7E00FEFF00FEFF00FEFF00FEFF00FC7E01FC7801F81E07F00F FFC001FE0017207E9F1C>I<0000E00001E00003E00003E00007E0000FE0001FE0001FE00037E0 0077E000E7E001C7E00187E00307E00707E00E07E00C07E01807E03807E07007E0E007E0FFFFFE FFFFFE0007E00007E00007E00007E00007E00007E00007E000FFFE00FFFE17207E9F1C>I<1000 201E01E01FFFC01FFF801FFF001FFE001FF8001BC00018000018000018000018000019FC001FFF 001E0FC01807E01803E00003F00003F00003F80003F83803F87C03F8FE03F8FE03F8FC03F0FC03 F07007E03007C01C1F800FFF0003F80015207D9F1C>I<001F8000FFE003F07007C0F00F01F81F 01F83E01F83E01F87E00F07C00007C0000FC0800FC7FC0FCFFE0FD80F0FF00F8FE007CFE007CFC 007EFC007EFC007EFC007E7C007E7C007E7C007E3C007C3E007C1E00F80F00F00783E003FFC000 FF0017207E9F1C>I<6000007800007FFFFE7FFFFE7FFFFC7FFFF87FFFF87FFFF0E00060E000C0 C00180C00300C00300000600000C00001C0000180000380000780000780000F00000F00000F000 01F00001F00001F00003F00003F00003F00003F00003F00003F00003F00001E00017227DA11C> I<00FE0003FFC00703E00E00F01C00F01C00783C00783E00783F00783F80783FE0F01FF9E01FFF C00FFF8007FFC003FFE007FFF01E7FF83C1FFC7807FC7801FEF000FEF0003EF0001EF0001EF000 1CF8001C7800383C00381F01F00FFFC001FF0017207E9F1C>I<01FE0007FF800F83E01E01F03E 00F07C00F87C0078FC007CFC007CFC007CFC007EFC007EFC007EFC007E7C00FE7C00FE3E01FE1E 037E0FFE7E07FC7E00207E00007C00007C1E007C3F00F83F00F83F00F03F01E01E03C01C0F800F FE0003F80017207E9F1C>I<387CFEFEFE7C380000000000000000387CFEFEFE7C3807167C9510> I<000070000000007000000000F800000000F800000000F800000001FC00000001FC00000003FE 00000003FE00000003FE00000006FF000000067F0000000E7F8000000C3F8000000C3F80000018 3FC00000181FC00000381FE00000300FE00000300FE00000600FF000006007F00000E007F80000 FFFFF80000FFFFF800018001FC00018001FC00038001FE00030000FE00030000FE000600007F00 0600007F00FFE00FFFF8FFE00FFFF825227EA12A>65 DI<0003FE0080001FFF818000FF01E38001F8003F8003E0001F8007C0000F800F800007 801F800007803F000003803F000003807F000001807E000001807E00000180FE00000000FE0000 0000FE00000000FE00000000FE00000000FE00000000FE00000000FE000000007E000000007E00 0001807F000001803F000001803F000003801F800003000F8000030007C000060003F0000C0001 F800380000FF00F000001FFFC0000003FE000021227DA128>IIII73 D 76 DI I<0007FC0000003FFF800000FC07E00003F001F80007E000FC000FC0007E001F80003F001F8000 3F003F00001F803F00001F807F00001FC07E00000FC07E00000FC0FE00000FE0FE00000FE0FE00 000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE07E00000FC07F 00001FC07F00001FC03F00001F803F80003F801F80003F000FC0007E0007E000FC0003F001F800 00FC07E000003FFF80000007FC000023227DA12A>II82 D<01FC0407FF8C1F03FC3C007C7C003C78001C78001CF8000CF8000CFC000CFC0000FF0000FFE0 007FFF007FFFC03FFFF01FFFF80FFFFC03FFFE003FFE0003FF00007F00003F00003FC0001FC000 1FC0001FE0001EE0001EF0003CFC003CFF00F8C7FFE080FF8018227DA11F>I<7FFFFFFF807FFF FFFF807E03F80F807803F807807003F803806003F80180E003F801C0E003F801C0C003F800C0C0 03F800C0C003F800C0C003F800C00003F800000003F800000003F800000003F800000003F80000 0003F800000003F800000003F800000003F800000003F800000003F800000003F800000003F800 000003F800000003F800000003F800000003F800000003F800000003F800000003F8000003FFFF F80003FFFFF80022227EA127>II<0400400E 00E0180180380380300300600600600600E00E00C00C00C00C00DC0DC0FE0FE0FF0FF0FF0FF07F 07F03E03E01C01C014117AA21D>92 D<07FC001FFF803F07C03F03E03F01E03F01F01E01F00001 F00001F0003FF003FDF01FC1F03F01F07E01F0FC01F0FC01F0FC01F0FC01F07E02F07E0CF81FF8 7F07E03F18167E951B>97 DI<00FF8007FFE00F83F01F03F03E03F07E03F07C01E07C0000FC0000FC0000FC0000FC0000 FC0000FC00007C00007E00007E00003E00301F00600FC0E007FF8000FE0014167E9519>I<0001 FE000001FE0000003E0000003E0000003E0000003E0000003E0000003E0000003E0000003E0000 003E0000003E0000003E0001FC3E0007FFBE000F81FE001F007E003E003E007E003E007C003E00 FC003E00FC003E00FC003E00FC003E00FC003E00FC003E00FC003E00FC003E007C003E007C003E 003E007E001E00FE000F83BE0007FF3FC001FC3FC01A237EA21F>I<00FE0007FF800F87C01E01 E03E01F07C00F07C00F8FC00F8FC00F8FFFFF8FFFFF8FC0000FC0000FC00007C00007C00007E00 003E00181F00300FC07003FFC000FF0015167E951A>I<003F8000FFC001E3E003C7E007C7E00F 87E00F83C00F80000F80000F80000F80000F80000F8000FFFC00FFFC000F80000F80000F80000F 80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F 80000F80007FF8007FF80013237FA211>I<03FC1E0FFF7F1F0F8F3E07CF3C03C07C03E07C03E0 7C03E07C03E07C03E03C03C03E07C01F0F801FFF0013FC003000003000003800003FFF801FFFF0 0FFFF81FFFFC3800FC70003EF0001EF0001EF0001EF0001E78003C7C007C3F01F80FFFE001FF00 18217E951C>II<1C00 3E007F007F007F003E001C000000000000000000000000000000FF00FF001F001F001F001F001F 001F001F001F001F001F001F001F001F001F001F001F001F001F00FFE0FFE00B247EA310>I108 DI I<00FE0007FFC00F83E01E00F03E00F87C007C7C007C7C007CFC007EFC007EFC007EFC007EFC00 7EFC007EFC007E7C007C7C007C3E00F81F01F00F83E007FFC000FE0017167E951C>II<00FE030007FF87000FC1C7001F006F003F003F007E003F007E 001F007C001F00FC001F00FC001F00FC001F00FC001F00FC001F00FC001F00FC001F007E001F00 7E001F003E003F001F007F000FC1DF0007FF9F0001FC1F0000001F0000001F0000001F0000001F 0000001F0000001F0000001F0000001F000000FFE00000FFE01B207E951E>II<0FF3003FFF00781F00600700 E00300E00300F00300FC00007FE0007FF8003FFE000FFF0001FF00000F80C00780C00380E00380 E00380F00700FC0E00EFFC00C7F00011167E9516>I<0180000180000180000180000380000380 000780000780000F80003F8000FFFF00FFFF000F80000F80000F80000F80000F80000F80000F80 000F80000F80000F80000F80000F81800F81800F81800F81800F81800F830007C30003FE0000F8 0011207F9F16>III120 D I<7FFFF07FFFF07C03E07007C0600FC0E01F80C01F00C03E00C07E0000FC0000F80001F00003F0 3007E03007C0300F80701F80703F00603E00E07C03E0FFFFE0FFFFE014167E9519>I E /Fh 11 121 df<70F8F8F87005057C840D>58 D<70F8FCFC74040404080810102040060E7C84 0D>I<00F1800389C00707800E03801C03803C0380380700780700780700780700F00E00F00E00 F00E00F00E10F01C20F01C20703C20705C40308C400F078014147E9318>97 D<007C01C207010E011C013C013802780C7BF07C00F000F000F000F00070007001700230041838 07C010147E9315>101 D<01E0000FE00001C00001C00001C00001C00003800003800003800003 80000700000700000701E00706100E08700E10F00E20F00E40601C80001D00001E00001FC00038 7000383800383800381C20703840703840703840701880E01880600F0014207E9F18>107 D<1E07802318C023A06043C0704380704380708700E00700E00700E00700E00E01C00E01C00E01 C00E03821C03841C07041C07081C03083803101801E017147E931B>110 D<03C1E004621804741C08781C08701E08701E10E01E00E01E00E01E00E01E01C03C01C03C01C0 3C01C0380380780380700380E003C1C0072380071E000700000700000E00000E00000E00000E00 001C00001C0000FFC000171D819317>112 D<00C000E001C001C001C001C003800380FFF80380 07000700070007000E000E000E000E001C001C001C001C10382038203820384018800F000D1C7F 9B10>116 D<0F00601180702180E021C0E041C0E04380E08381C00701C00701C00701C00E0380 0E03800E03800E03840E07080C07080C07080E0F1006131003E1E016147E931A>I<0F01801183 C02183E021C1E041C0E04380608380400700400700400700400E00800E00800E00800E01000E01 000C02000E04000E040006180001E00013147E9316>I<03C1C00C62201034701038F02038F020 386040700000700000700000700000E00000E00000E00000E02061C040F1C040F1C080E2C08044 6300383C0014147E931A>120 D E /Fi 86 127 df<70F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8 70000000000070F8F8F870051C779B18>33 D<4010E038F078E038E038E038E038E038E038E038 E038E038E03860300D0E7B9C18>I<00C00001C00001C00001C00003F0000FFC003FFE007DCF00 71C700E1C380E1C780E1C780E1C780F1C00079C0003DC0001FE0000FF80003FC0001DE0001CF00 01C70061C380F1C380F1C380E1C380E1C70071C70079DE003FFE001FF80007E00001C00001C000 01C00000C00011247D9F18>36 D<3803007C07807C0780EE0F80EE0F00EE0F00EE1F00EE1E00EE 1E00EE3E007C3C007C3C00387C0000780000780000F80000F00001F00001E00001E00003E00003 C00003C00007C0000783800787C00F87C00F0EE00F0EE01F0EE01E0EE01E0EE03E0EE03C07C03C 07C018038013247E9F18>I<01C00007E0000FF0000E70001C38001C38001C38001C38001C73F0 1C73F01CE3F00FE3800FC7000F87000F07001F0E003F0E007B8E0073DC00E1DC00E0F800E0F800 E07070E0787070FC707FFFE03FCFE00F03C0141C7F9B18>I<387C7C7E3E0E0E0E1C1C38F8F0C0 070E789B18>I<007000F001E003C007800F001E001C00380038007000700070007000E000E000 E000E000E000E000E000E0007000700070007000380038001C001E000F00078003C001F000F000 700C24799F18>I<6000F00078003C001E000F000780038001C001C000E000E000E000E0007000 7000700070007000700070007000E000E000E000E001C001C0038007800F001E003C007800F000 60000C247C9F18>I<01C00001C00001C00001C000C1C180F1C780F9CF807FFF001FFC0007F000 07F0001FFC007FFF00F9CF80F1C780C1C18001C00001C00001C00001C00011147D9718>I<0060 0000F00000F00000F00000F00000F00000F00000F0007FFFC0FFFFE0FFFFE07FFFC000F00000F0 0000F00000F00000F00000F00000F00000600013147E9718>I<1C3E7E7F3F1F070E1E7CF86008 0C788518>I<7FFF00FFFF80FFFF807FFF0011047D8F18>I<3078FCFC78300606778518>I<0003 00000780000780000F80000F00001F00001E00001E00003E00003C00007C0000780000780000F8 0000F00001F00001E00003E00003C00003C00007C0000780000F80000F00000F00001F00001E00 003E00003C00003C00007C0000780000F80000F00000F0000060000011247D9F18>I<01F00007 FC000FFE001F1F001C07003803807803C07001C07001C0E000E0E000E0E000E0E000E0E000E0E0 00E0E000E0E000E0E000E0F001E07001C07001C07803C03803801C07001F1F000FFE0007FC0001 F000131C7E9B18>I<01800380038007800F803F80FF80FB804380038003800380038003800380 03800380038003800380038003800380038003807FFCFFFE7FFC0F1C7B9B18>I<03F0000FFE00 3FFF007C0F807003C0E001C0F000E0F000E06000E00000E00000E00001C00001C00003C0000780 000F00001E00003C0000780000F00001E00007C0000F80001E00E03C00E07FFFE0FFFFE07FFFE0 131C7E9B18>I<07F8001FFE003FFF007807807803C07801C03001C00001C00003C0000380000F 0003FF0003FE0003FF000007800003C00001C00000E00000E00000E0F000E0F000E0F001C0F003 C07C07803FFF001FFE0003F800131C7E9B18>I<001F00003F0000770000770000E70001E70001 C7000387000787000707000E07001E07003C0700380700780700F00700FFFFF8FFFFF8FFFFF800 0700000700000700000700000700000700007FF000FFF8007FF0151C7F9B18>I<1FFF803FFF80 3FFF803800003800003800003800003800003800003800003800003BF8003FFE003FFF003C0780 1803C00001C00000E00000E06000E0F000E0F000E0E001C07003C07C0F803FFF001FFC0003F000 131C7E9B18>I<007E0001FF0007FF800F83C01E03C01C03C0380180380000700000700000E1F8 00E7FE00FFFF00FE0780F803C0F001C0F000E0E000E0F000E07000E07000E07000E03801C03C03 C01E07800FFF0007FE0001F800131C7E9B18>II<03F800 0FFE001FFF003E0F803803807001C07001C07001C07001C03803803C07801FFF0007FC000FFE00 1F1F003C07807001C0F001E0E000E0E000E0E000E0E000E07001C07803C03E0F801FFF000FFE00 03F800131C7E9B18>I<03F0000FFC001FFE003C0F00780780700380E001C0E001C0E001C0E001 E0E001E07001E07803E03C0FE01FFFE00FFEE003F0E00000E00001C00001C00001C03003807807 80780F00783E003FFC001FF00007C000131C7E9B18>I<3078FCFC783000000000000000003078 FCFC78300614779318>I<183C7E7E3C180000000000000000183C7E7E3E1E0E1C3C78F060071A 789318>I<000300000780001F80003F00007E0001FC0003F00007E0001FC0003F00007E0000FC 0000FC00007E00003F00001FC00007E00003F00001FC00007E00003F00001F8000078000030011 187D9918>I<7FFFC0FFFFE0FFFFE0FFFFE0000000000000000000000000FFFFE0FFFFE0FFFFE0 7FFFC0130C7E9318>I<600000F00000FC00007E00003F00001FC00007E00003F00001FC00007E 00003F00001F80001F80003F00007E0001FC0003F00007E0001FC0003F00007E0000FC0000F000 0060000011187D9918>I<007C0001FE0007FF000F87801E03C03C1DC0387FC070FFE071E3E071 C1E0E1C1E0E380E0E380E0E380E0E380E0E380E0E380E0E1C1C071C1C071E3C070FF80387F003C 1C001E00E00F83E007FFC001FF80007E00131C7E9B18>64 D<00700000F80000F80000D80000D8 0001DC0001DC0001DC00018C00038E00038E00038E00038E000306000707000707000707000707 000FFF800FFF800FFF800E03800E03801C01C01C01C07F07F0FF8FF87F07F0151C7F9B18>II<00F8E003FEE007FFE00F07E01E03E03C01E03800E07000E07000E0 700000E00000E00000E00000E00000E00000E00000E00000E000007000007000E07000E03800E0 3C00E01E01C00F07C007FF8003FE0000F800131C7E9B18>I<7FF800FFFE007FFF001C0F801C03 C01C03C01C01E01C00E01C00E01C00F01C00701C00701C00701C00701C00701C00701C00701C00 701C00F01C00E01C00E01C01E01C01C01C03C01C0F807FFF00FFFE007FF800141C7F9B18>III<01F1C003FDC00FFFC01F0FC01C03 C03803C03801C07001C07001C0700000E00000E00000E00000E00000E00000E00FF0E01FF0E00F F07001C07001C07003C03803C03803C01C07C01F0FC00FFFC003FDC001F1C0141C7E9B18>I<7F 07F0FF8FF87F07F01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01FFFC01F FFC01FFFC01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C07F07F0FF 8FF87F07F0151C7F9B18>I<7FFF00FFFF807FFF0001C00001C00001C00001C00001C00001C000 01C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C000 01C00001C00001C0007FFF00FFFF807FFF00111C7D9B18>I<7FE000FFE0007FE0000E00000E00 000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00 000E00000E00000E00700E00700E00700E00700E00707FFFF0FFFFF07FFFF0141C7F9B18>76 DI<7E07F0FF0FF87F07F01D81C01D81C01D81C01DC1C01CC1C01C C1C01CE1C01CE1C01CE1C01C61C01C71C01C71C01C31C01C39C01C39C01C39C01C19C01C19C01C 1DC01C0DC01C0DC01C0DC07F07C0FF87C07F03C0151C7F9B18>I<0FF8003FFE007FFF00780F00 700700F00780E00380E00380E00380E00380E00380E00380E00380E00380E00380E00380E00380 E00380E00380E00380E00380E00380F00780700700780F007FFF003FFE000FF800111C7D9B18> II<7FF800FFFE007FFF001C0F801C03801C03C01C01C01C01C01C 01C01C03C01C03801C0F801FFF001FFE001FFE001C0F001C07001C03801C03801C03801C03801C 03801C039C1C039C1C039C7F01F8FF81F87F00F0161C7F9B18>82 D<03F3801FFF803FFF807C0F 80700780E00380E00380E00380E000007000007800003F00001FF00007FE0000FF00000F800003 C00001C00000E00000E06000E0E000E0E001E0F001C0F80780FFFF80FFFE00E7F800131C7E9B18 >I<7FFFF8FFFFF8FFFFF8E07038E07038E07038E0703800700000700000700000700000700000 700000700000700000700000700000700000700000700000700000700000700000700000700007 FF0007FF0007FF00151C7F9B18>I86 DI<7F8FE07F9FE07F8FE00E07000F0700070E00078E00039C0003DC0001F80001F80000F000 00F00000700000F00000F80001F80001DC00039E00038E00070F000707000E07800E03801E03C0 7F07F0FF8FF87F07F0151C7F9B18>I91 D<600000F00000F00000F800007800007C00003C0000 3C00003E00001E00001F00000F00000F00000F800007800007C00003C00003C00003E00001E000 01F00000F00000F800007800007800007C00003C00003E00001E00001E00001F00000F00000F80 00078000078000030011247D9F18>II<018007C01FF07EFCF83EE00E0F067C9B18>I<7FFF00FF FF80FFFF807FFF0011047D7F18>I<061E3E387070E0E0E0F8FC7C7C38070E789E18>I<1FE0003F F8007FFC00781E00300E0000070000070000FF0007FF001FFF007F0700780700E00700E00700E0 0700F00F00781F003FFFF01FFBF007E1F014147D9318>I<7E0000FE00007E00000E00000E0000 0E00000E00000E00000E3E000EFF800FFFC00FC1E00F80E00F00700E00700E00380E00380E0038 0E00380E00380E00380F00700F00700F80E00FC1E00FFFC00EFF80063E00151C809B18>I<01FE 0007FF001FFF803E0780380300700000700000E00000E00000E00000E00000E00000E000007000 007001C03801C03E03C01FFF8007FF0001FC0012147D9318>I<001F80003F80001F8000038000 038000038000038000038003E3800FFB801FFF803C1F80380F80700780700380E00380E00380E0 0380E00380E00380E00380700780700780380F803C1F801FFFF00FFBF803E3F0151C7E9B18>I< 01F00007FC001FFE003E0F00380780700380700380E001C0E001C0FFFFC0FFFFC0FFFFC0E00000 7000007001C03801C03E03C01FFF8007FF0001FC0012147D9318>I<001F80007FC000FFE000E1 E001C0C001C00001C00001C0007FFFC0FFFFC0FFFFC001C00001C00001C00001C00001C00001C0 0001C00001C00001C00001C00001C00001C00001C00001C0007FFF007FFF007FFF00131C7F9B18 >I<01E1F007FFF80FFFF81E1E301C0E003807003807003807003807003807001C0E001E1E001F FC001FF80039E0003800001C00001FFE001FFFC03FFFE07801F0700070E00038E00038E00038E0 00387800F07E03F01FFFC00FFF8001FC00151F7F9318>I<7E0000FE00007E00000E00000E0000 0E00000E00000E00000E3E000EFF800FFFC00FC1C00F80E00F00E00E00E00E00E00E00E00E00E0 0E00E00E00E00E00E00E00E00E00E00E00E00E00E07FC3FCFFE7FE7FC3FC171C809B18>I<0380 0007C00007C00007C0000380000000000000000000000000007FC000FFC0007FC00001C00001C0 0001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C000FFFF 00FFFF80FFFF00111D7C9C18>I<0038007C007C007C003800000000000000000FFC1FFC0FFC00 1C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C 001C001C6038F078FFF07FE03F800E277E9C18>II<7FE000FFE0 007FE00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E0 0000E00000E00000E00000E00000E00000E00000E00000E00000E00000E0007FFFC0FFFFE07FFF C0131C7E9B18>I<7CE0E000FFFBF8007FFFF8001F1F1C001E1E1C001E1E1C001C1C1C001C1C1C 001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C007F1F 1F00FFBFBF807F1F1F001914819318>I<7E3E00FEFF807FFFC00FC1C00F80E00F00E00E00E00E 00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E07FC3FCFFE7FE7FC3FC17 14809318>I<01F0000FFE001FFF003E0F803803807001C07001C0E000E0E000E0E000E0E000E0 E000E0F001E07001C07803C03C07803E0F801FFF000FFE0001F00013147E9318>I<7E3E00FEFF 807FFFC00FC1E00F80E00F00700E00700E00380E00380E00380E00380E00380E00380F00700F00 700F80E00FC1E00FFFC00EFF800E3E000E00000E00000E00000E00000E00000E00000E00007FC0 00FFE0007FC000151E809318>I<01E38007FB801FFF803E1F80380F80700780700780E00380E0 0380E00380E00380E00380E00380700780700780380F803C1F801FFF800FFB8003E38000038000 0380000380000380000380000380000380003FF8003FF8003FF8151E7E9318>I<7F87E0FF9FF0 7FBFF803F87803F03003E00003C00003C000038000038000038000038000038000038000038000 0380000380007FFE00FFFF007FFE0015147F9318>I<07F7003FFF007FFF00780F00E00700E007 00E007007C00007FE0001FFC0003FE00001F00600780E00380E00380F00380F80F00FFFF00FFFC 00E7F00011147D9318>I<0180000380000380000380000380007FFFC0FFFFC0FFFFC003800003 80000380000380000380000380000380000380000380000380400380E00380E00380E001C1C001 FFC000FF80003E0013197F9818>I<7E07E0FE0FE07E07E00E00E00E00E00E00E00E00E00E00E0 0E00E00E00E00E00E00E00E00E00E00E00E00E00E00E01E00F03E007FFFC03FFFE01FCFC171480 9318>I<7F8FF0FF8FF87F8FF01E03C00E03800E03800E0380070700070700070700038E00038E 00038E00038E0001DC0001DC0001DC0000F80000F80000700015147F9318>II<7F8FF07F9FF07F8FF0070700078E00039E00 01DC0001F80000F80000700000F00000F80001DC00039E00038E000707000F07807F8FF0FF8FF8 7F8FF015147F9318>I<7F8FF0FF8FF87F8FF00E01C00E03800E03800703800707000707000387 00038600038E0001CE0001CE0000CC0000CC0000DC000078000078000078000070000070000070 0000F00000E00079E0007BC0007F80003F00001E0000151E7F9318>I<3FFFF07FFFF07FFFF070 01E07003C0700780000F00001E00003C0000F80001F00003C0000780000F00701E00703C007078 0070FFFFF0FFFFF0FFFFF014147F9318>I<0007E0001FE0007FE000780000E00000E00000E000 00E00000E00000E00000E00000E00000E00000E00000E00001E0007FC000FF8000FF80007FC000 01E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E000007800 007FE0001FE00007E013247E9F18>I<60F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0 F0F0F0F0F0F0F0F0F0F0F0F0600424769F18>I<7C0000FF0000FFC00003C00000E00000E00000 E00000E00000E00000E00000E00000E00000E00000E00000E00000F000007FC0003FE0003FE000 7FC000F00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00003 C000FFC000FF00007C000013247E9F18>I<060C1F1E3FBEFBF8F1F060C00F067C9B18>I E /Fj 59 123 df<0003E0001C1800381800703C00E03C00E03801C00001C00001C00001C00001 C0000380007FFFF00380700380700380700380700700E00700E00700E00700E00700E00700E00E 01C00E01C00E01C00E01C00E01C00E01C01C03801E03C0FF0FF816207E9F19>12 D<381C7C3E7C3E7E3F3A1D040204020402080408041008201040208040100E7A9F17>34 D<1C3E7E7E3A0202040408081020C0070E7D840D>44 DI<3078F87870 05057C840D>I<00000400000C00000C0000180000180000300000300000600000600000C00000 C0000180000180000300000300000600000600000C00000C000018000018000030000030000060 0000600000C00000C0000180000180000300000300000600000600000600000C00000C00001800 00180000300000300000600000600000C00000C00000800000162D7EA117>I<000C001C00FC0F 380038003800380038003800700070007000700070007000E000E000E000E000E000E001C001C0 01C001C001C001C0038003C0FFFE0F1E7C9D17>49 D<003F8000C1E00100F00200780400780400 780F007C0F807C0F807C0F00780600780000F80000F00001E00001C0000380000700000E00001C 0000380000600000C0000180000300200600200800401000403FFFC07FFF80FFFF80161E7E9D17 >I<007F000183C00201E00400F00700F00F00F00F01F00F01F00001E00001E00003C000038000 0700000E0000F800000E000007000007800007C00003C00007C03007C07807C0F807C0F807C0F0 0780800F00400E00201C0018780007E000141F7D9D17>I<0000600000600000E00001C00003C0 0005C0000DC00009C00011C000238000438000C380008380010380020380040700080700180700 100700200700400700FFFFF0000E00000E00000E00000E00000E00001C00001E0001FFE0141E7E 9D17>I<01803001FFE003FFC003FF0003FC00020000020000020000040000040000040000047C 000587000603800C01800801C00001C00001E00001E00001E00001E07003C0F803C0F003C0E003 80800780400700400E00201C0018700007C000141F7D9D17>I<000F8000704000C0200180E003 01E00701E00E00C01E00001C00003C000038000078F800790E007A07007C0300F80380F80380F0 03C0F003C0F003C0F003C0F00780E00780E00780E00700E00F00600E00701C0030180018700007 C000131F7C9D17>I<2000003FFFE07FFFC07FFF80400100C00200800200800400000800001000 0020000040000040000080000180000300000300000700000600000E00000E00001E00001C0000 1C00003C00003C00003C0000780000780000780000300000131F799D17>I<003F0000C1C00100 600200600400300C00300C00300C00300C00600E00600F80C00FC18007F60003FC0001FC0001FF 00063F800C0F801007C03003C06001C06000C0C000C0C000C0C000C0C00080C001006003003004 0018180007E000141F7D9D17>I<007E0001C3000301800601C00E01C01C00C03C00E03C00E03C 01E07801E07801E07801E07801E07803E07803E03803C03807C01C0BC00C13C003E38000078000 0780000700000E00600E00F01C00F01800E0300080600041C0003F0000131F7C9D17>I<000010 0000001800000038000000380000007800000078000000FC000001BC0000013C0000033C000002 3C0000063C0000043E0000081E0000081E0000101E0000101E0000201E0000200F0000400F0000 400F0000FFFF0000800F0001000F8001000780020007800200078004000780040007800C0007C0 3E0007C0FF807FFC1E207E9F22>65 D<07FFFF00007C01C0003C01E0003C00F0007800F8007800 F8007800F8007800F8007800F8007800F000F001F000F001E000F003C000F00F8000FFFE0000F0 0F0001E007C001E003C001E003E001E001E001E001E001E001E003C001E003C003E003C003E003 C003C003C007C003C00F8007800F0007803E00FFFFF0001D1F7E9E20>I<0001F808000E061800 380138007000F801E0007803C0007007800030078000300F0000301F0000301E0000303E000020 3C0000007C0000007C0000007C0000007C000000F8000000F8000000F8000000F8000000F80000 007800004078000080780000803C0000803C0001001C0002000E00020006000C000300100001C0 E000003F00001D217B9F21>I<07FFFF00007C01E0003C00F0003C00780078003C0078003C0078 001E0078001E0078001E0078001F00F0001F00F0001F00F0001F00F0001F00F0001F00F0001F01 E0001E01E0003E01E0003E01E0003E01E0003C01E0007C03C0007803C000F003C000F003C001E0 03C003C003C0078007800F0007803C00FFFFE000201F7E9E23>I<07FFFFF8007C0078003C0038 003C001800780018007800080078000800780008007800080078080800F0100000F0100000F010 0000F0300000FFF00000F0700001E0200001E0200001E0200001E0200001E0000801E0001003C0 001003C0001003C0002003C0002003C0006003C000C0078001C0078007C0FFFFFF801D1F7E9E1F >I<07FFFFF8007C0078003C0038003C0018007800180078000800780008007800080078000800 78000800F0100000F0100000F0100000F0300000F0700000FFF00001E0600001E0200001E02000 01E0200001E0200001E0000003C0000003C0000003C0000003C0000003C0000003C00000078000 0007C00000FFFE00001D1F7E9E1E>I<0001FC04000F030C003C009C0070007C00E0003C01C000 3803800018078000180F0000181F0000181E0000183E0000103C0000007C0000007C0000007C00 00007C000000F8000000F8000000F8007FFCF80003E0780001E0780001E0780003C0780003C03C 0003C03C0003C01C0003C00E0007C007000B800380118001E06080003F80001E217B9F24>I<07 FFC7FFC0007C00F800003C007800003C007800007800F000007800F000007800F000007800F000 007800F000007800F00000F001E00000F001E00000F001E00000F001E00000FFFFE00000F001E0 0001E003C00001E003C00001E003C00001E003C00001E003C00001E003C00003C007800003C007 800003C007800003C007800003C007800003C007800007800F000007C00F8000FFF8FFF800221F 7E9E22>I<07FFE0007C00003C00003C0000780000780000780000780000780000780000F00000 F00000F00000F00000F00000F00001E00001E00001E00001E00001E00001E00003C00003C00003 C00003C00003C00003C00007800007C000FFFC00131F7F9E10>I<07FFF000007E0000003C0000 003C000000780000007800000078000000780000007800000078000000F0000000F0000000F000 0000F0000000F0000000F0000001E0000001E0000001E0000001E0000001E0008001E0010003C0 010003C0010003C0030003C0020003C0060003C0060007801E0007807C00FFFFFC00191F7E9E1C >76 D<07FC0000FFC0007C0000F800003C00017800003C00017800004E0002F000004E0002F000 004E0004F000004E0004F000004E0008F000004E0008F00000870011E00000870011E000008700 21E00000870021E00000870041E00000838041E00001038083C00001038083C00001038103C000 01038203C0000101C203C0000101C403C0000201C40780000201C80780000201C80780000201D0 0780000200F00780000600E00780000600E00F00000F00C00F8000FFE0C1FFF8002A1F7E9E2A> I<07FC01FFC0003E003E00003E001800003E001800004F001000004F0010000047801000004780 10000043C010000043C010000083C020000081E020000081E020000080F020000080F020000080 782000010078400001007C400001003C400001003C400001001E400001001E400002000F800002 000F800002000F800002000780000200078000060003800006000300000F00010000FFE0010000 221F7E9E22>I<0003F800001E0E000038070000E0038001C001C003C001E0078000E00F0000F0 0F0000F01E0000F01E0000F83E0000F83C0000F87C0000F87C0000F87C0000F87C0000F8F80001 F0F80001F0F80001F0F80001F0F80003E0780003E0780003C0780007C07C0007803C000F003C00 1E001E001C000E0038000700F00003C3C00000FE00001D217B9F23>I<07FFFF00007C03C0003C 01E0003C00F0007800F0007800F8007800F8007800F8007800F8007800F000F001F000F001E000 F003C000F0078000F00F0000FFF80001E0000001E0000001E0000001E0000001E0000001E00000 03C0000003C0000003C0000003C0000003C0000003C000000780000007C00000FFFC00001D1F7E 9E1F>I<07FFFC00007C0700003C03C0003C01E0007801E0007801F0007801F0007801F0007801 F0007801E000F003E000F003C000F0078000F00F0000F03C0000FFF00001E0300001E0380001E0 1C0001E01C0001E01C0001E01E0003C03E0003C03E0003C03E0003C03E0003C03E0003C03E0207 803E0407C01F04FFFC0F18000003E01F207E9E21>82 D<003F040060CC01803C03801C03001C07 00180600080E00080E00080E00080E00000F00000F80000FE00007FE0003FF8001FFC0007FE000 07E00001E00000E00000F00000F04000E04000E04000E04000E06000C0600180E00380F80300C6 0C0081F80016217D9F19>I<3FFFFFF03C0780F03007803060078030400F0010400F0010C00F00 10800F0010800F0010800F0010001E0000001E0000001E0000001E0000001E0000001E0000003C 0000003C0000003C0000003C0000003C0000003C00000078000000780000007800000078000000 7800000078000000F0000001F800007FFFE0001C1F7A9E21>III<03FFC0FFC0007F007E00003E00380000 1E003000001E002000000F004000000F008000000F81000000078200000007C600000003C40000 0003E800000001F000000001F000000000F000000000F800000000F8000000017C000000023C00 0000043C0000000C1E000000081E000000101F000000200F000000400F800000C0078000008007 C000010003C000070003E0001F8007E000FFE01FFE00221F7F9E22>88 DI<060308041008201020104020402080408040B85CF87CF87CF87C7038100E779F17> 92 D<07F8000C0C001E06001E07001C070000070000070000070000FF0007C7001E07003C0E00 780E00F00E10F00E10F00E10F01E10F02E20784F401F878014147D9317>97 D<0700003F00000F00000700000700000E00000E00000E00000E00000E00000E00001C00001C7C 001D87001E03801C01C01C01C03801C03801E03801E03801E03801E03801E07003C07003C07003 80700780700700700E00E81C00C4380083E00013207B9F19>I<01FC07060E0F1C0F380E780070 00F000F000F000F000E000E000E000E000F0027004300818300FC010147C9314>I<0000700003 F00000F00000700000700000E00000E00000E00000E00000E00000E00001C000F9C00305C00E03 C01C03C03801C0780380700380F00380F00380F00380F00380E00700E00700E00700E00700E007 00700F00301E00186F000F8FE014207C9F19>I<00F800070E000E07001C070038038078038070 0380F00380F00380FFFF80F00000E00000E00000E00000E00000F001007002003004001C180007 E00011147D9314>I<0007800018C00031E00061E000E1C000C00001C00001C00001C00001C000 01C0000380007FF800038000038000038000038000070000070000070000070000070000070000 0E00000E00000E00000E00000E00000E00001C00001E0000FFE00013207E9F0E>I<00000E003E 1100E1A301C1C20381E00780E00701E00F01E00F01E00F01E00703C007038007870004FC000800 000800001800001C00000FFF000FFFC007FFE01800F0300030600030C00030C00030C000306000 603000C01C070007FC00181F809417>I<00E00007E00001E00000E00000E00001C00001C00001 C00001C00001C00001C000038000038F800390E003A0E003C0600380600780E00700E00700E007 00E00700E00700E00E01C00E01C00E01C00E01C00E01C00E01C01C03801E03C0FFCFF815207E9F 19>I<01C003E003E003C0018000000000000000000000000003801F8007800380038007000700 07000700070007000E000E000E000E000E000E001C001E00FF800B1F7F9E0C>I<00E007E001E0 00E000E001C001C001C001C001C001C00380038003800380038003800700070007000700070007 000E000E000E000E000E000E001C001E00FFC00B207F9F0C>108 D<0387C07C001F9861860007 A072070003C0340300038038030007807807000700700700070070070007007007000700700700 07007007000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E001C01C01C 001E01E01E00FFCFFCFFC022147E9326>I<038F801F90E007A0E003C0600380600780E00700E0 0700E00700E00700E00700E00E01C00E01C00E01C00E01C00E01C00E01C01C03801E03C0FFCFF8 15147E9319>I<00FC000387000E01801C00C03800E03800E07000F0F000F0F000F0F000F0F000 F0E001E0E001E0E001C0E003C0F00380700700380E001C1C0007E00014147D9317>I<00E3E007 EC3800F01C00E01E00E00E01C00E01C00F01C00F01C00F01C00F01C00F03801E03801E03801C03 803C0380380380700740E00721C0071F000700000700000700000E00000E00000E00000E00001E 0000FFC000181D809319>I<038E001FB38007C78003C780038300078000070000070000070000 0700000700000E00000E00000E00000E00000E00000E00001C00001E0000FFE00011147E9312> 114 D<01F2060E080618061802380438001E001FE00FF003F8003C401C400C400C600C6018E010 D0608FC00F147E9312>I<0080010001000100030007000F001E00FFF80E000E000E000E001C00 1C001C001C001C001C00380038203820382038203840384018800F000D1C7C9B12>I<1C0380FC 1F803C07801C03801C0380380700380700380700380700380700380700700E00700E00700E0070 0E00701E00701E00703C00305E001F9FC012147B9319>II<1FF0FF03C07801C06001C04000E08000E180007300007600003C 00003C00001C00002E00004E000087000107000203800603800C01C03E03E0FF07FC18147F9318 >120 D<0FF83F8001E00E0001C00C0001C0080000E0180000E0100000E0200000E0200000F040 000070400000708000007080000071000000390000003A0000003E0000003C0000003800000018 0000001000000010000000200000002000000040000070C00000F0800000F1000000E20000007C 000000191D809318>I<07FFE00701E00401C00C0380080700080E00101C000038000070000070 0000E00001C0000380800700800E00801C01001C0100380300700E00FFFE0013147F9314>I E /Fk 55 123 df<00FC7C0183C607078E0607040E07000E07000E07000E07000E07000E0700FF FFF00E07000E07000E07000E07000E07000E07000E07000E07000E07000E07000E07000E07000E 07000E07007F0FF0171A809916>11 D<00FC000182000703000607000E02000E00000E00000E00 000E00000E0000FFFF000E07000E07000E07000E07000E07000E07000E07000E07000E07000E07 000E07000E07000E07000E07007F0FE0131A809915>I<60F0F0F0F0F0F0606060606060606060 60200000000060F0F060041A7D990B>33 D<60C0F1E0F9F068D0081008100810102010202040C1 800C0B7F9913>I<60F0F868080808101020C0050B7D990B>39 D<00800100020004000C000800 18003000300030006000600060006000E000E000E000E000E000E000E000E000E000E000600060 0060006000300030003000180008000C00040002000100008009267D9B0F>I<80004000200010 00180008000C000600060006000300030003000300038003800380038003800380038003800380 038003000300030003000600060006000C0008001800100020004000800009267E9B0F>I<60F0 F07010101020204080040B7D830B>44 DI<60F0F06004047D830B>I<01 E006100C1818383038300070006000E000E7C0E860F030F018E018E01CE01CE01C601C601C7018 30183030186007C00E187E9713>54 D<078018603030201860186018601870103C303E600F8007 C019F030F86038401CC00CC00CC00CC00C6008201018600FC00E187E9713>56 D<60F0F060000000000000000060F0F06004107D8F0B>58 D<60F0F060000000000000000060F0 F0701010102020408004177D8F0B>I<000C0000000C0000000C0000001E0000001E0000003F00 0000270000002700000043800000438000004380000081C0000081C0000081C0000100E0000100 E00001FFE000020070000200700006007800040038000400380008001C0008001C001C001E00FF 00FFC01A1A7F991D>65 DI<003F0201C0C603002E0E001E1C000E1C0006380006 780002700002700002F00000F00000F00000F00000F00000F00000700002700002780002380004 1C00041C00080E000803003001C0C0003F00171A7E991C>I70 D72 DI76 DII80 D82 D<0FC21836200E6006C006C002C002C002E00070007E003FE01FF807FC003E000E0007 0003800380038003C002C006E004D81887E0101A7E9915>I<7FFFFF00701C0700401C0100401C 0100C01C0180801C0080801C0080801C0080001C0000001C0000001C0000001C0000001C000000 1C0000001C0000001C0000001C0000001C0000001C0000001C0000001C0000001C0000001C0000 001C0000001C000003FFE000191A7F991C>I87 D<1830204040804080810081008100B160F9F078F030600C0B7B9913>92 D<3F8070C070E020700070007007F01C7030707070E070E071E071E0F171FB1E3C10107E8F13> 97 DI<07F80C1C381C30087000E000E000E000E000E000E0007000300438080C 1807E00E107F8F11>I<007E00000E00000E00000E00000E00000E00000E00000E00000E00000E 0003CE000C3E00380E00300E00700E00E00E00E00E00E00E00E00E00E00E00E00E00600E00700E 00381E001C2E0007CFC0121A7F9915>I<07C01C3030187018600CE00CFFFCE000E000E000E000 6000300438080C1807E00E107F8F11>I<01F0031807380E100E000E000E000E000E000E00FFC0 0E000E000E000E000E000E000E000E000E000E000E000E000E000E007FE00D1A80990C>I<0FCE 187330307038703870387038303018602FC02000600070003FF03FFC1FFE600FC003C003C003C0 036006381C07E010187F8F13>II<18003C003C00180000000000000000000000 0000FC001C001C001C001C001C001C001C001C001C001C001C001C001C001C00FF80091A80990A >I<018003C003C001800000000000000000000000000FC001C001C001C001C001C001C001C001 C001C001C001C001C001C001C001C001C001C001C041C0E180E3007E000A2182990C>IIIII<07E01C38300C 700E6006E007E007E007E007E007E0076006700E381C1C3807E010107F8F13>II<03C2000C2600381E 00300E00700E00E00E00E00E00E00E00E00E00E00E00E00E00700E00700E00381E001C2E0007CE 00000E00000E00000E00000E00000E00000E00007FC012177F8F14>II<1F2060E04020C020C020 F0007F003FC01FE000F080708030C030C020F0408F800C107F8F0F>I<0400040004000C000C00 1C003C00FFC01C001C001C001C001C001C001C001C001C201C201C201C201C200E4003800B177F 960F>IIIIII<7FF86070407040E041C041C00380070007000E081C081C08381070107030FFF00D107F 8F11>I E /Fl 10 58 df<1F00318060C04040C060C060C060C060C060C060C060C060404060C0 31801F000B107F8F0F>48 D<0C003C00CC000C000C000C000C000C000C000C000C000C000C000C 000C00FF8009107E8F0F>I<1F00618040C08060C0600060006000C00180030006000C00102020 207FC0FFC00B107F8F0F>I<1F00218060C060C000C0008001800F00008000400060C060C06080 4060801F000B107F8F0F>I<0300030007000F000B001300330023004300C300FFE00300030003 0003001FE00B107F8F0F>I<20803F002C002000200020002F0030802040006000600060C06080 C061801F000B107F8F0F>I<0780184030C060C06000C000CF00F080E040C060C060C060406060 C030801F000B107F8F0F>I<40007FE07FC08080808001000200040004000C0008000800180018 001800180018000B117E900F>I<1F00318060C060C060C071803F000F00338061C0C060C060C0 60404060801F000B107F8F0F>I<1F00318060C0C040C060C060C06040E021E01E600060004060 C0608043003E000B107F8F0F>I E /Fm 11 58 df<003000003000003000003000003000003000 003000003000003000003000003000FFFFFCFFFFFC003000003000003000003000003000003000 00300000300000300000300000300016187E931B>43 D<07C018303018701C600C600CE00EE00E E00EE00EE00EE00EE00EE00EE00E600C600C701C30181C7007C00F157F9412>48 D<03000700FF000700070007000700070007000700070007000700070007000700070007000700 07007FF00C157E9412>I<0F8030E040708030C038E0384038003800700070006000C001800300 06000C08080810183FF07FF0FFF00D157E9412>I<0FE030306018701C701C001C001800380060 07E000300018000C000E000EE00EE00EC00C401830300FE00F157F9412>I<00300030007000F0 01F001700270047008701870107020704070C070FFFE0070007000700070007003FE0F157F9412 >I<20303FE03FC0240020002000200020002F8030E020700030003800384038E038E038803040 6020C01F000D157E9412>I<01F00608080C181C301C70006000E000E3E0EC30F018F00CE00EE0 0EE00E600E600E300C3018183007C00F157F9412>I<40007FFE7FFC7FF8C00880108020004000 8000800100010003000200060006000E000E000E000E000E0004000F167E9512>I<07E0183020 18600C600C700C78183E101F600FC00FF018F8607C601EC00EC006C006C004600C38300FE00F15 7F9412>I<07C0183030186018E00CE00CE00EE00EE00E601E301E186E0F8E000E000C001C7018 7018603020C01F800F157F9412>I E /Fn 9 121 df0 D<01800180018001800180C183F18F399C0FF003C003C00FF0399CF18FC1830180018001800180 018010147D9417>3 D<03C00FF01FF83FFC7FFE7FFEFFFFFFFFFFFFFFFFFFFFFFFF7FFE7FFE3F FC1FF80FF003C010127D9317>15 D17 D21 D<000002000000000300000000030000000001 8000000000C000000000C00000000060007FFFFFF000FFFFFFFC000000000E0000000003800000 0001F0000000007C00000000F000000003C000000007000000000C00FFFFFFF8007FFFFFF00000 00006000000000C00000000180000000018000000003000000000300000000020000261A7D972D >41 D<400001C0000360000660000660000630000C30000C30000C1800181800181800180FFFF0 0FFFF00C00300600600600600600600300C00300C001818001818001818000C30000C30000C300 006600006600006600003C00003C00003C000018000018001821809F19>56 D<00040000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C 0000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C0000000C000000 0C0000000C0000000C0000000C0000000C0000000C0000000C0000FFFFFFE0FFFFFFE01B1C7C9B 23>63 D<0F80184030207010E030E070E020E000E00060007000300018000600198030C0706060 70E030E038E038E03860387030307018600CC0030000C000600070003000380038203870386038 4070206010C00F800D297D9F14>120 D E /Fo 50 123 df<00003F03E00000C386700001878C F00003879CF00003031860000700380000070038000007003800000E003800000E007000000E00 7000000E00700000FFFFFF80001C007000001C00E000001C00E000001C00E000001C00E0000038 00E000003801C000003801C000003801C000003801C000007001C0000070038000007003800000 700380000070038000006003800000E007000000E007000000E007000000E007000000C0060000 01C00E000001C00E000031860C0000798F180000F31E100000620C6000003C07C000002429829F 1C>11 D<00003FE00000E010000180380003807800030078000700300007000000070000000700 00000E0000000E0000000E000000FFFFE0000E00E0001C01C0001C01C0001C01C0001C01C0001C 03800038038000380380003803800038070000380700007007000070071000700E2000700E2000 700E2000E00E2000E0064000E0038000E0000000C0000001C0000001C000003180000079800000 F3000000620000003C0000001D29829F1A>I<1C3C3C3C3C040408081020204080060E7D840E> 44 D<7FF0FFE07FE00C037D8A10>I<70F8F8F0E005057B840E>I<00000040000000C000000180 000001800000030000000300000006000000060000000C00000018000000180000003000000030 00000060000000C0000000C0000001800000018000000300000003000000060000000C0000000C 0000001800000018000000300000003000000060000000C0000000C00000018000000180000003 00000003000000060000000C0000000C0000001800000018000000300000003000000060000000 C0000000C0000000800000001A2D7FA117>I<000F800030E000E07001C0700380300380380700 380F00780F00780E00781E00781E00703C00F03C00F03C00F03C00F07801E07801E07801E07801 C07003C0F003C0F00380F00780F00700700700700E00701C003038001870000FC000151F7C9D17 >I<000200020006000E003C00DC031C001C0038003800380038007000700070007000E000E000 E000E001C001C001C001C003800380038003800780FFF80F1E7B9D17>I<001F000061800080E0 0100E00200700220700420700410700820F00820F00820F00840E00881E00703C0000380000700 000C000018000060000080000300000400000800401000401000802001807E030047FF0041FE00 80FC00807800141F7C9D17>I<070F1F1F0E0000000000000000000070F8F8F0E008147B930E> 58 D<00000200000006000000060000000E0000001E0000001E0000003F0000002F0000004F00 00004F0000008F0000010F0000010F0000020F0000020F0000040F00000C0F0000080F0000100F 0000100F0000200F80003FFF800040078000C00780008007800100078001000780020007800200 0780060007801E000F80FF807FF81D207E9F22>65 D<0000FE0200078186001C004C0038003C00 60003C00C0001C01C0001803800018070000180F0000181E0000101E0000103C0000003C000000 78000000780000007800000078000000F0000000F0000000F0000000F0000000F0000080700000 8070000080700001003800010038000200180004000C001800060020000381C00000FE00001F21 7A9F21>67 D<01FFFFFC001E0038001E0018001E0008001E0008003C0008003C0008003C000800 3C00080078001000780800007808000078080000F0100000F0300000FFF00000F0300001E02000 01E0200001E0200001E0200003C0000003C0000003C0000003C000000780000007800000078000 00078000000F800000FFF800001E1F7D9E1E>70 D<0000FC040007030C001C00980030007800E0 007801C000380380003003800030070000300E0000301E0000201E0000203C0000003C00000078 000000780000007800000078000000F0000000F000FFF0F0000780F0000780F0000F0070000F00 70000F0070000F0070001E0038001E0018003E001C002E000E00CC000383040000FC00001E217A 9F23>I<01FFF3FFE0001F003E00001E003C00001E003C00001E003C00003C007800003C007800 003C007800003C007800007800F000007800F000007800F000007800F00000F001E00000FFFFE0 0000F001E00000F001E00001E003C00001E003C00001E003C00001E003C00003C007800003C007 800003C007800003C007800007800F000007800F000007800F000007800F00000F801F0000FFF1 FFE000231F7D9E22>I<01FFF0001F00001E00001E00001E00003C00003C00003C00003C000078 0000780000780000780000F00000F00000F00000F00001E00001E00001E00001E00003C00003C0 0003C00003C0000780000780000780000780000F8000FFF800141F7D9E12>I<01FFF800001F00 00001E0000001E0000001E0000003C0000003C0000003C0000003C000000780000007800000078 00000078000000F0000000F0000000F0000000F0000001E0000001E0000001E0000001E0008003 C0010003C0010003C0030003C00200078006000780060007800C0007801C000F007800FFFFF800 191F7D9E1D>76 D<01FE00007FC0001E0000FC00001E0000F80000170001780000170001780000 270002F00000270004F00000270004F00000270008F00000470009E00000470011E00000470021 E00000470021E00000870043C00000838043C00000838083C00000838083C00001038107800001 03820780000103820780000103840780000203840F00000203880F00000203900F00000203900F 00000401E01E00000401E01E00000401C01E00000C01801E00001C01803E0000FF8103FFC0002A 1F7D9E29>I<01FF007FE0001F000F00001F0004000017800400001780040000278008000023C0 08000023C008000023C008000041E010000041E010000041F010000040F010000080F020000080 7820000080782000008078200001003C400001003C400001003C400001001E400002001E800002 001E800002000F800002000F800004000F0000040007000004000700000C000700001C00020000 FF80020000231F7D9E22>I<0001FC0000070700001C01C0003000E000E0006001C00070038000 7007800038070000380E0000381E0000381C0000383C0000383C00003878000078780000787800 007878000078F00000F0F00000F0F00000E0F00001E0F00001C0F00003C0700003807000070078 000F0038001E0038003C001C0070000E00E0000783800001FC00001D217A9F23>I<01FFFF8000 1E00E0001E0070001E0038001E003C003C003C003C003C003C003C003C003C0078007800780078 007800F0007800E000F003C000F00F0000FFFC0000F0000001E0000001E0000001E0000001E000 0003C0000003C0000003C0000003C00000078000000780000007800000078000000F800000FFF0 00001E1F7D9E1F>I<0007E040001C18C0003005800060038000C0038001C00180018001000380 010003800100038001000380000003C0000003C0000003F8000001FF800001FFE000007FF00000 1FF0000001F8000000780000007800000038000000380020003800200038002000300060007000 600060006000E0007000C000E8038000C606000081F800001A217D9F1A>83 D<0FFFFFF01E0780E0180780201007802020078020200F0020600F0020400F0020400F0020801E 0040001E0000001E0000001E0000003C0000003C0000003C0000003C0000007800000078000000 7800000078000000F0000000F0000000F0000000F0000001E0000001E0000001E0000001E00000 03E00000FFFF00001C1F789E21>I86 D<00F1800389C00707800E03801C03803C0380380700780700780700780700F00E00F00E00F00E 00F00E20F01C40F01C40703C40705C40308C800F070013147C9317>97 D<07803F800700070007 0007000E000E000E000E001C001C001CF01D0C3A0E3C0E380F380F700F700F700F700FE01EE01E E01EE01CE03CE038607060E031C01F0010207B9F15>I<007E0001C1000300800E07801E07801C 07003C0200780000780000780000F00000F00000F00000F00000F0000070010070020030040018 380007C00011147C9315>I<0000780003F80000700000700000700000700000E00000E00000E0 0000E00001C00001C000F1C00389C00707800E03801C03803C0380380700780700780700780700 F00E00F00E00F00E00F00E20F01C40F01C40703C40705C40308C800F070015207C9F17>I<007C 01C207010E011C013C013802780C7BF07C00F000F000F000F0007000700170023804183807C010 147C9315>I<00007800019C00033C00033C000718000700000700000E00000E00000E00000E00 000E0001FFE0001C00001C00001C00001C00003800003800003800003800003800007000007000 00700000700000700000700000E00000E00000E00000E00000C00001C00001C000018000318000 7B0000F300006600003C00001629829F0E>I<003C6000E27001C1E00380E00700E00F00E00E01 C01E01C01E01C01E01C03C03803C03803C03803C03803C07003C07001C0F001C17000C2E0003CE 00000E00000E00001C00001C00301C00783800F0700060E0003F8000141D7E9315>I<01E0000F E00001C00001C00001C00001C000038000038000038000038000070000070000071E000763000E 81800F01C00E01C00E01C01C03801C03801C03801C0380380700380700380700380E10700E2070 0C20701C20700C40E00CC060070014207D9F17>I<00C001E001E001C000000000000000000000 000000000E003300230043804300470087000E000E000E001C001C001C00384038803080708031 0033001C000B1F7C9E0E>I<0001800003C00003C0000380000000000000000000000000000000 000000000000003C00004600008700008700010700010700020E00000E00000E00000E00001C00 001C00001C00001C0000380000380000380000380000700000700000700000700000E00000E000 30E00079C000F180006300003C00001228829E0E>I<01E0000FE00001C00001C00001C00001C0 000380000380000380000380000700000700000703C00704200E08E00E11E00E21E00E40C01C80 001D00001E00001FC00038E000387000387000383840707080707080707080703100E03100601E 0013207D9F15>I<03C01FC0038003800380038007000700070007000E000E000E000E001C001C 001C001C0038003800380038007000700070007100E200E200E200E200640038000A207C9F0C> I<1C0F80F0002630C318004740640C004780680E004700700E004700700E008E00E01C000E00E0 1C000E00E01C000E00E01C001C01C038001C01C038001C01C038001C01C0708038038071003803 806100380380E10038038062007007006600300300380021147C9325>I<1C0F802630C0474060 4780604700704700708E00E00E00E00E00E00E00E01C01C01C01C01C01C01C0384380388380308 3807083803107003303001C016147C931A>I<007C0001C3000301800E01C01E01C01C01E03C01 E07801E07801E07801E0F003C0F003C0F003C0F00780F00700700F00700E0030180018700007C0 0013147C9317>I<01C1E002621804741C04781C04701E04701E08E01E00E01E00E01E00E01E01 C03C01C03C01C03C01C0380380780380700380E003C1C0072380071E000700000700000E00000E 00000E00000E00001C00001C0000FFC000171D809317>I<00F0400388C00705800E03801C0380 3C0380380700780700780700780700F00E00F00E00F00E00F00E00F01C00F01C00703C00705C00 30B8000F380000380000380000700000700000700000700000E00000E0000FFE00121D7C9315> I<1C1E002661004783804787804707804703008E00000E00000E00000E00001C00001C00001C00 001C000038000038000038000038000070000030000011147C9313>I<00FC030206010C030C07 0C060C000F800FF007F803FC003E000E700EF00CF00CE008401020601F8010147D9313>I<0180 01C0038003800380038007000700FFF007000E000E000E000E001C001C001C001C003800380038 003820704070407080708031001E000C1C7C9B0F>I<0E00C03300E02301C04381C04301C04701 C08703800E03800E03800E03801C07001C07001C07001C07101C0E20180E20180E201C1E200C26 4007C38014147C9318>I<0E03803307802307C04383C04301C04700C08700800E00800E00800E 00801C01001C01001C01001C02001C02001C04001C04001C08000E300003C00012147C9315>I< 0E00C1C03300E3C02301C3E04381C1E04301C0E04701C060870380400E0380400E0380400E0380 401C0700801C0700801C0700801C0701001C0701001C0602001C0F02000C0F04000E13080003E1 F0001B147C931E>I<0383800CC4401068E01071E02071E02070C040E00000E00000E00000E000 01C00001C00001C00001C040638080F38080F38100E5810084C60078780013147D9315>I<0E00 C03300E02301C04381C04301C04701C08703800E03800E03800E03801C07001C07001C07001C07 001C0E00180E00180E001C1E000C3C0007DC00001C00001C00003800F03800F07000E06000C0C0 004380003E0000131D7C9316>I<01C04003E08007F1800C1F0008020000040000080000100000 20000040000080000100000200000401000802001002003E0C0063FC0041F80080E00012147D93 13>I E /Fp 81 125 df<001F83E000F06E3001C078780380F8780300F0300700700007007000 0700700007007000070070000700700007007000FFFFFF80070070000700700007007000070070 000700700007007000070070000700700007007000070070000700700007007000070070000700 7000070070000700700007007000070070007FE3FF001D20809F1B>11 D<003F0000E0C001C0C0 0381E00701E00701E0070000070000070000070000070000070000FFFFE00700E00700E00700E0 0700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E0 0700E00700E07FC3FE1720809F19>I<003FE000E0E001C1E00381E00700E00700E00700E00700 E00700E00700E00700E00700E0FFFFE00700E00700E00700E00700E00700E00700E00700E00700 E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E07FE7FE1720809F19 >I<001F81F80000F04F040001C07C06000380F80F000300F00F000700F00F0007007000000700 7000000700700000070070000007007000000700700000FFFFFFFF000700700700070070070007 007007000700700700070070070007007007000700700700070070070007007007000700700700 070070070007007007000700700700070070070007007007000700700700070070070007007007 007FE3FE3FF02420809F26>I<70F8F8F8F8F8F8F8707070707070707070702020202020000000 000070F8F8F87005217CA00D>33 D<7038F87CFC7EFC7E743A0402040204020804080410081008 201040200F0E7E9F17>I<70F8FCFC74040404080810102040060E7C9F0D>39 D<0020004000800100020006000C000C00180018003000300030007000600060006000E000E000 E000E000E000E000E000E000E000E000E000E0006000600060007000300030003000180018000C 000C000600020001000080004000200B2E7DA112>I<800040002000100008000C000600060003 00030001800180018001C000C000C000C000E000E000E000E000E000E000E000E000E000E000E0 00E000C000C000C001C001800180018003000300060006000C00080010002000400080000B2E7D A112>I<70F8FCFC74040404080810102040060E7C840D>44 DI<70F8F8 F87005057C840D>I<000100030003000600060006000C000C000C001800180018003000300030 00600060006000C000C000C00180018001800300030003000600060006000C000C000C00180018 001800300030003000600060006000C000C000C000102D7DA117>I<03F0000E1C001C0E001806 00380700700380700380700380700380F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003 C0F003C0F003C0F003C0F003C0F003C07003807003807003807807803807001806001C0E000E1C 0003F000121F7E9D17>I<018003800F80F3800380038003800380038003800380038003800380 0380038003800380038003800380038003800380038003800380038007C0FFFE0F1E7C9D17>I< 03F0000C1C00100E00200700400780800780F007C0F803C0F803C0F803C02007C00007C0000780 000780000F00000E00001C0000380000700000600000C0000180000300000600400C0040180040 1000803FFF807FFF80FFFF80121E7E9D17>I<03F0000C1C00100E00200F00780F807807807807 80380F80000F80000F00000F00000E00001C0000380003F000003C00000E00000F000007800007 800007C02007C0F807C0F807C0F807C0F00780400780400F00200E001C3C0003F000121F7E9D17 >I<000600000600000E00000E00001E00002E00002E00004E00008E00008E00010E00020E0002 0E00040E00080E00080E00100E00200E00200E00400E00C00E00FFFFF0000E00000E00000E0000 0E00000E00000E00000E0000FFE0141E7F9D17>I<1803001FFE001FFC001FF8001FE000100000 10000010000010000010000010000011F000161C00180E001007001007800003800003800003C0 0003C00003C07003C0F003C0F003C0E00380400380400700200600100E000C380003E000121F7E 9D17>I<007C000182000701000E03800C07801C0780380300380000780000700000700000F1F0 00F21C00F40600F80700F80380F80380F003C0F003C0F003C0F003C0F003C07003C07003C07003 803803803807001807000C0E00061C0001F000121F7E9D17>I<4000007FFFC07FFF807FFF8040 010080020080020080040000080000080000100000200000200000400000400000C00000C00001 C00001800003800003800003800003800007800007800007800007800007800007800007800003 0000121F7D9D17>I<03F0000C0C00100600300300200180600180600180600180700180780300 3E03003F06001FC8000FF00003F80007FC000C7E00103F00300F806003804001C0C001C0C000C0 C000C0C000C0C000806001802001001002000C0C0003F000121F7E9D17>I<03F0000E18001C0C 00380600380700700700700380F00380F00380F003C0F003C0F003C0F003C0F003C07007C07007 C03807C0180BC00E13C003E3C0000380000380000380000700300700780600780E00700C002018 001070000FC000121F7E9D17>I<70F8F8F8700000000000000000000070F8F8F87005147C930D> I<70F8F8F8700000000000000000000070F0F8F878080808101010202040051D7C930D>I<7FFF FFE0FFFFFFF00000000000000000000000000000000000000000000000000000000000000000FF FFFFF07FFFFFE01C0C7D9023>61 D<0FC0307040384038E03CF03CF03C603C0038007000E000C0 01800180010003000200020002000200020002000000000000000000000007000F800F800F8007 000E207D9F15>63 D<000100000003800000038000000380000007C0000007C0000007C0000009 E0000009E0000009E0000010F0000010F0000010F00000207800002078000020780000403C0000 403C0000403C0000801E0000801E0000FFFE0001000F0001000F0001000F000200078002000780 02000780040003C00E0003C01F0007E0FFC03FFE1F207F9F22>65 DI<000FC040007030C001C009C0038005C0070003C00E0001C01E0000C01C0000C03C0000C0 7C0000407C00004078000040F8000000F8000000F8000000F8000000F8000000F8000000F80000 00F8000000F8000000780000007C0000407C0000403C0000401C0000401E0000800E0000800700 01000380020001C0040000703800000FC0001A217D9F21>II< FFFFFF000F800F0007800300078003000780010007800180078000800780008007800080078080 800780800007808000078080000781800007FF8000078180000780800007808000078080000780 8000078000200780002007800020078000400780004007800040078000C0078000C0078001800F 800F80FFFFFF801B1F7E9E1F>II<000FE0200078186000E004 E0038002E0070001E00F0000E01E0000601E0000603C0000603C0000207C00002078000020F800 0000F8000000F8000000F8000000F8000000F8000000F8000000F8007FFCF80003E0780001E07C 0001E03C0001E03C0001E01E0001E01E0001E00F0001E0070001E0038002E000E0046000781820 000FE0001E217D9F24>III<0FFFC0007C00003C00003C00003C00003C00003C00003C 00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C 00003C00003C00203C00F83C00F83C00F83C00F0380040780040700030E0000F800012207E9E17 >IIIII<001F800000F0F00001C0380007801E000F000F00 0E0007001E0007803C0003C03C0003C07C0003E0780001E0780001E0F80001F0F80001F0F80001 F0F80001F0F80001F0F80001F0F80001F0F80001F0F80001F0780001E07C0003E07C0003E03C00 03C03C0003C01E0007800E0007000F000F0007801E0001C0380000F0F000001F80001C217D9F23 >II82 D<07E0800C1980100780300380600180600180E00180E00080E00080E00080F00000F000007800 007F00003FF0001FFC000FFE0003FF00001F800007800003C00003C00001C08001C08001C08001 C08001C0C00180C00380E00300F00600CE0C0081F80012217D9F19>I<7FFFFFE0780F01E0600F 0060400F0020400F0020C00F0030800F0010800F0010800F0010800F0010000F0000000F000000 0F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000 000F0000000F0000000F0000000F0000000F0000000F0000000F0000001F800007FFFE001C1F7E 9E21>II II89 D91 D<080410082010201040204020804080408040B85CFC7EFC7E7C3E381C0F0E7B9F17>II<1FE000303000781800781C00300E00000E00000E00000E0000FE00078E 001E0E00380E00780E00F00E10F00E10F00E10F01E10781E103867200F83C014147E9317>97 D<0E0000FE00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E3E 000EC3800F01C00F00E00E00E00E00700E00700E00780E00780E00780E00780E00780E00780E00 700E00700E00E00F00E00D01C00CC300083E0015207F9F19>I<03F80E0C1C1E381E380C700070 00F000F000F000F000F000F00070007000380138011C020E0C03F010147E9314>I<000380003F 8000038000038000038000038000038000038000038000038000038000038003E380061B801C07 80380380380380700380700380F00380F00380F00380F00380F00380F003807003807003803803 803807801C07800E1B8003E3F815207E9F19>I<03F0000E1C001C0E0038070038070070070070 0380F00380F00380FFFF80F00000F00000F000007000007000003800801800800C010007060001 F80011147F9314>I<007C00C6018F038F07060700070007000700070007000700FFF007000700 07000700070007000700070007000700070007000700070007000700070007007FF01020809F0E >I<0000E003E3300E3C301C1C30380E00780F00780F00780F00780F00780F00380E001C1C001E 380033E0002000002000003000003000003FFE001FFF800FFFC03001E0600070C00030C00030C0 0030C000306000603000C01C038003FC00141F7F9417>I<0E0000FE00000E00000E00000E0000 0E00000E00000E00000E00000E00000E00000E00000E3E000E43000E81800F01C00F01C00E01C0 0E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C0 FFE7FC16207F9F19>I<1C001E003E001E001C000000000000000000000000000E007E000E000E 000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E00FFC00A1F809E0C> I<00E001F001F001F000E0000000000000000000000000007007F000F000700070007000700070 00700070007000700070007000700070007000700070007000700070007000706070F060F0C061 803F000C28829E0E>I<0E0000FE00000E00000E00000E00000E00000E00000E00000E00000E00 000E00000E00000E0FF00E03C00E03000E02000E04000E08000E10000E30000E70000EF8000F38 000E1C000E1E000E0E000E07000E07800E03800E03C00E03E0FFCFF815207F9F18>I<0E00FE00 0E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E 000E000E000E000E000E000E000E000E000E00FFE00B20809F0C>I<0E1F01F000FE618618000E 81C81C000F00F00E000F00F00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E00 0E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E 000E00E00E00FFE7FE7FE023147F9326>I<0E3E00FE43000E81800F01C00F01C00E01C00E01C0 0E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C0FFE7FC 16147F9319>I<01F800070E001C03803801C03801C07000E07000E0F000F0F000F0F000F0F000 F0F000F0F000F07000E07000E03801C03801C01C0380070E0001F80014147F9317>I<0E3E00FE C3800F01C00F00E00E00E00E00F00E00700E00780E00780E00780E00780E00780E00780E00700E 00F00E00E00F01E00F01C00EC3000E3E000E00000E00000E00000E00000E00000E00000E00000E 0000FFE000151D7F9319>I<03E0800619801C05803C0780380380780380700380F00380F00380 F00380F00380F00380F003807003807803803803803807801C0B800E138003E380000380000380 000380000380000380000380000380000380003FF8151D7E9318>I<0E78FE8C0F1E0F1E0F0C0E 000E000E000E000E000E000E000E000E000E000E000E000E000E00FFE00F147F9312>I<1F9030 704030C010C010C010E00078007F803FE00FF00070803880188018C018C018E030D0608F800D14 7E9312>I<020002000200060006000E000E003E00FFF80E000E000E000E000E000E000E000E00 0E000E000E000E080E080E080E080E080610031001E00D1C7F9B12>I<0E01C0FE1FC00E01C00E 01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E 03C00603C0030DC001F1FC16147F9319>III<7FC3FC0F01E00701C007018003810001C20000E40000EC 00007800003800003C00007C00004E000087000107000303800201C00601E01E01E0FF07FE1714 809318>II<3FFF380E200E201C40384078407000E001E0 01C00380078007010E011E011C0338027006700EFFFE10147F9314>III E /Fq 48 122 df<1C0038007F00FE007F00FE00FF81FF00FFC1FF 80FFC1FF807FC0FF807FC0FF801CC0398000C0018000C001800180030001800300018003000300 06000300060006000C000C00180018003000300060002000400019157EA924>34 D<1C007F007F00FF80FFC0FFC07FC07FC01CC000C000C00180018001800300030006000C001800 300020000A157B8813>44 D<00000300000007800000078000000F8000000F0000000F0000001F 0000001E0000003E0000003C0000003C0000007C0000007800000078000000F8000000F0000001 F0000001E0000001E0000003E0000003C0000003C0000007C00000078000000F8000000F000000 0F0000001F0000001E0000003E0000003C0000003C0000007C0000007800000078000000F80000 00F0000001F0000001E0000001E0000003E0000003C0000003C0000007C00000078000000F8000 000F0000000F0000001F0000001E0000001E0000003E0000003C0000007C000000780000007800 0000F8000000F0000000F000000060000000193C7CAC22>47 D<003F800001FFF00007E0FC000F C07E001F803F001F803F003F001F803F001F807F001FC07F001FC07F001FC07F001FC0FF001FE0 FF001FE0FF001FE0FF001FE0FF001FE0FF001FE0FF001FE0FF001FE0FF001FE0FF001FE0FF001F E0FF001FE0FF001FE0FF001FE0FF001FE07F001FC07F001FC07F001FC07F001FC03F001F803F00 1F801F803F001F803F000FC07E0007E0FC0001FFF000003F80001B277DA622>I<000E00001E00 007E0007FE00FFFE00FFFE00F8FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE00 00FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE00 00FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE007FFFFE7FFFFE7FFFFE17277BA622> I<00FF800003FFF0000FFFFC001F03FE003800FF007C007F80FE003FC0FF003FC0FF003FE0FF00 1FE0FF001FE07E001FE03C003FE000003FE000003FC000003FC000007F8000007F000000FE0000 00FC000001F8000003F0000003E00000078000000F0000001E0000003C00E0007000E000E000E0 01C001C0038001C0070001C00FFFFFC01FFFFFC03FFFFFC07FFFFFC0FFFFFF80FFFFFF80FFFFFF 801B277DA622>I<007F800003FFF00007FFFC000F81FE001F00FF003F80FF003F807F803F807F 803F807F801F807F800F007F800000FF000000FF000000FE000001FC000001F8000007F00000FF C00000FFF0000001FC0000007E0000007F0000007F8000003FC000003FC000003FE000003FE03C 003FE07E003FE0FF003FE0FF003FE0FF003FC0FF007FC07E007F807C007F003F01FE001FFFFC00 07FFF00000FF80001B277DA622>I<00000E0000001E0000003E0000007E000000FE000000FE00 0001FE000003FE0000077E00000E7E00000E7E00001C7E0000387E0000707E0000E07E0000E07E 0001C07E0003807E0007007E000E007E000E007E001C007E0038007E0070007E00E0007E00FFFF FFF8FFFFFFF8FFFFFFF80000FE000000FE000000FE000000FE000000FE000000FE000000FE0000 00FE00007FFFF8007FFFF8007FFFF81D277EA622>I<0C0003000F803F000FFFFE000FFFFC000F FFF8000FFFF0000FFFE0000FFFC0000FFE00000E0000000E0000000E0000000E0000000E000000 0E0000000E7FC0000FFFF8000F80FC000E003E000C003F0000001F8000001FC000001FC000001F E000001FE018001FE07C001FE0FE001FE0FE001FE0FE001FE0FE001FC0FC001FC078003F807800 3F803C007F001F01FE000FFFF80003FFF00000FF80001B277DA622>I<0007F000003FFC0000FF FE0001FC0F0003F01F8007E03F800FC03F801FC03F801F803F803F801F003F8000007F0000007F 0000007F000000FF000000FF0FC000FF3FF800FF707C00FFC03E00FFC03F00FF801F80FF801FC0 FF001FC0FF001FE0FF001FE0FF001FE07F001FE07F001FE07F001FE07F001FE03F001FE03F001F C01F801FC01F803F800FC03F0007E07E0003FFFC0000FFF000003FC0001B277DA622>I<380000 003E0000003FFFFFF03FFFFFF03FFFFFF07FFFFFE07FFFFFC07FFFFF807FFFFF0070000E007000 0E0070001C00E0003800E0007000E000E0000000E0000001C00000038000000780000007800000 0F0000000F0000001F0000001F0000003F0000003E0000003E0000007E0000007E0000007E0000 007E000000FE000000FE000000FE000000FE000000FE000000FE000000FE000000FE0000007C00 00003800001C297CA822>I<003FC00001FFF00003FFFC0007C07E000F003F001E001F001E000F 803E000F803E000F803F000F803F000F803FC00F003FF01F001FFC1E001FFE3C000FFFF80007FF E00003FFF80001FFFC0001FFFE0007FFFF000F0FFF801E03FFC03C01FFC07C007FE078001FE0F8 0007E0F80007E0F80003E0F80003E0F80003E0F80003C07C0003C07C0007803F000F001FC03E00 0FFFFC0003FFF800007FC0001B277DA622>I<007F800001FFF00007FFF8000FE0FC001F807E00 3F803F007F003F007F001F80FF001F80FF001FC0FF001FC0FF001FC0FF001FE0FF001FE0FF001F E0FF001FE07F001FE07F003FE03F003FE01F807FE00F807FE007C1DFE003FF9FE0007E1FE00000 1FE000001FC000001FC000001FC000003F801F003F803F803F003F803F003F807E003F807C001F 01F8001E03F0000FFFE00007FF800001FE00001B277DA622>I<000003800000000007C0000000 0007C0000000000FE0000000000FE0000000000FE0000000001FF0000000001FF0000000003FF8 000000003FF8000000003FF80000000073FC0000000073FC00000000F3FE00000000E1FE000000 00E1FE00000001C0FF00000001C0FF00000003C0FF80000003807F80000007807FC0000007003F C0000007003FC000000E003FE000000E001FE000001E001FF000001C000FF000001FFFFFF00000 3FFFFFF800003FFFFFF80000780007FC0000700003FC0000700003FC0000E00001FE0000E00001 FE0001E00001FF0001C00000FF0001C00000FF00FFFE001FFFFEFFFE001FFFFEFFFE001FFFFE2F 297EA834>65 D<00003FF001800003FFFE0380000FFFFF8780003FF007DF8000FF8001FF8001FE 00007F8003FC00003F8007F000001F800FF000000F801FE0000007801FE0000007803FC0000007 803FC0000003807FC0000003807F80000003807F8000000000FF8000000000FF8000000000FF80 00000000FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF80000000 007F80000000007F80000000007FC0000003803FC0000003803FC0000003801FE0000003801FE0 000007000FF00000070007F000000E0003FC00001E0001FE00003C0000FF8000F800003FF007E0 00000FFFFFC0000003FFFF000000003FF8000029297CA832>67 D69 DI<00007FE003000003FFFC0700001FFFFF 0F00003FF00FFF0000FF8001FF0001FE0000FF0003F800003F0007F000003F000FF000001F001F E000000F001FE000000F003FC000000F003FC0000007007FC0000007007F80000007007F800000 0000FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF 8000000000FF8000000000FF8001FFFFF87F8001FFFFF87F8001FFFFF87FC00000FF003FC00000 FF003FC00000FF001FE00000FF001FE00000FF000FF00000FF0007F00000FF0003F80000FF0001 FE0000FF0000FF8001FF00003FF007BF00001FFFFF1F000003FFFE0F0000007FF003002D297CA8 36>I73 D 77 D<0000FFE000000007FFFC0000003FC07F8000007F001FC00001FC0007F00003F80003F800 07F00001FC000FF00001FE001FE00000FF001FE00000FF003FC000007F803FC000007F807FC000 007FC07F8000003FC07F8000003FC07F8000003FC0FF8000003FE0FF8000003FE0FF8000003FE0 FF8000003FE0FF8000003FE0FF8000003FE0FF8000003FE0FF8000003FE0FF8000003FE0FF8000 003FE07F8000003FC07FC000007FC07FC000007FC03FC000007F803FC000007F801FE00000FF00 1FE00000FF000FF00001FE0007F00001FC0003F80003F80001FC0007F00000FF001FE000003FC0 7F8000000FFFFE00000000FFE000002B297CA834>79 D I82 D<7FFFFFFFFFC07FFFFFFFFFC07FFFFFFFFFC0 7F803FC03FC07E003FC007C078003FC003C078003FC003C070003FC001C0F0003FC001E0F0003F C001E0E0003FC000E0E0003FC000E0E0003FC000E0E0003FC000E0E0003FC000E000003FC00000 00003FC0000000003FC0000000003FC0000000003FC0000000003FC0000000003FC0000000003F C0000000003FC0000000003FC0000000003FC0000000003FC0000000003FC0000000003FC00000 00003FC0000000003FC0000000003FC0000000003FC0000000003FC0000000003FC0000000003F C0000000003FC00000007FFFFFE000007FFFFFE000007FFFFFE0002B287EA730>84 D86 D<010002000300060006000C000C001800 1800300030006000300060006000C0006000C0006000C000C0018000C0018000CE019C00FF81FF 00FF81FF00FFC1FF80FFC1FF807FC0FF803F807F003F807F000E001C00191578A924>92 D<01FF800007FFF0000F81F8001FC07E001FC07E001FC03F000F803F8007003F8000003F800000 3F8000003F80000FFF8000FFFF8007FC3F800FE03F803F803F803F003F807F003F80FE003F80FE 003F80FE003F80FE003F807E007F807F00DF803F839FFC0FFF0FFC01FC03FC1E1B7E9A21>97 D<001FF80000FFFE0003F01F0007E03F800FC03F801F803F803F801F007F800E007F0000007F00 0000FF000000FF000000FF000000FF000000FF000000FF000000FF0000007F0000007F0000007F 8000003F8001C01F8001C00FC0038007E0070003F01E0000FFFC00001FE0001A1B7E9A1F>99 D<00003FF80000003FF80000003FF800000003F800000003F800000003F800000003F800000003 F800000003F800000003F800000003F800000003F800000003F800000003F800000003F800001F E3F80000FFFBF80003F03FF80007E00FF8000FC007F8001F8003F8003F8003F8007F0003F8007F 0003F8007F0003F800FF0003F800FF0003F800FF0003F800FF0003F800FF0003F800FF0003F800 FF0003F8007F0003F8007F0003F8007F0003F8003F8003F8001F8003F8000F8007F80007C00FF8 0003F03BFF8000FFF3FF80003FC3FF80212A7EA926>I<003FE00001FFF80003F07E0007C01F00 0F801F801F800F803F800FC07F000FC07F0007C07F0007E0FF0007E0FF0007E0FFFFFFE0FFFFFF E0FF000000FF000000FF0000007F0000007F0000007F0000003F8000E01F8000E00FC001C007E0 038003F81F0000FFFE00001FF0001B1B7E9A20>I<0007F0003FFC00FE3E01F87F03F87F03F07F 07F07F07F03E07F00007F00007F00007F00007F00007F00007F000FFFFC0FFFFC0FFFFC007F000 07F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F000 07F00007F00007F00007F00007F00007F00007F0007FFF807FFF807FFF80182A7EA915>I<00FF 81F003FFE7F80FC1FE7C1F80FC7C1F007C383F007E107F007F007F007F007F007F007F007F007F 007F007F007F003F007E001F007C001F80FC000FC1F8001FFFE00018FF80003800000038000000 3C0000003E0000003FFFF8001FFFFF001FFFFF800FFFFFC007FFFFE01FFFFFF03E0007F07C0001 F8F80000F8F80000F8F80000F8F80000F87C0001F03C0001E01F0007C00FC01F8003FFFE00007F F0001E287E9A22>II<07000F801FC03FE0 3FE03FE01FC00F8007000000000000000000000000000000FFE0FFE0FFE00FE00FE00FE00FE00F E00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE0FFFEFFFEFFFE 0F2B7DAA14>I107 DIII<003FE00001FFFC0003F07E 000FC01F801F800FC03F800FE03F0007E07F0007F07F0007F07F0007F0FF0007F8FF0007F8FF00 07F8FF0007F8FF0007F8FF0007F8FF0007F8FF0007F87F0007F07F0007F03F800FE03F800FE01F 800FC00FC01F8007F07F0001FFFC00003FE0001D1B7E9A22>II114 D<03FE300FFFF01E03F03800F0700070F00070F00070F80070FC0000FFE0007FFE00 7FFF803FFFE01FFFF007FFF800FFF80003FC0000FC60007CE0003CF0003CF00038F80038FC0070 FF01E0F7FFC0C1FF00161B7E9A1B>I<00700000700000700000700000F00000F00000F00001F0 0003F00003F00007F0001FFFF0FFFFF0FFFFF007F00007F00007F00007F00007F00007F00007F0 0007F00007F00007F00007F00007F00007F00007F03807F03807F03807F03807F03807F03803F0 3803F87001F86000FFC0001F8015267FA51B>IIIIII E /Fr 33 122 df<70F8F8F87005057C840E>46 D<0001800000018000000180000003C0000003 C0000003C0000005E0000005E000000DF0000008F0000008F0000010F800001078000010780000 203C0000203C0000203C0000401E0000401E0000401E0000800F0000800F0000FFFF0001000780 01000780030007C0020003C0020003C0040003E0040001E0040001E00C0000F00C0000F03E0001 F8FF800FFF20237EA225>65 D<0007E0100038183000E0063001C00170038000F0070000F00E00 00701E0000701C0000303C0000303C0000307C0000107800001078000010F8000000F8000000F8 000000F8000000F8000000F8000000F8000000F800000078000000780000107C0000103C000010 3C0000101C0000201E0000200E000040070000400380008001C0010000E0020000381C000007E0 001C247DA223>67 DI70 D72 D<03FFF0001F00000F00000F00000F00000F00000F00000F00000F0000 0F00000F00000F00000F00000F00000F00000F00000F00000F00000F00000F00000F00000F0000 0F00000F00000F00000F00700F00F80F00F80F00F80E00F01E00401C0020380018700007C00014 237EA119>74 D76 D78 D80 D<03F0200C0C601802603001E07000E0600060E00060E000 60E00020E00020E00020F00000F000007800007F00003FF0001FFE000FFF0003FF80003FC00007 E00001E00000F00000F0000070800070800070800070800070C00060C00060E000C0F000C0C801 80C6070081FC0014247DA21B>83 D85 D89 D<0FE0001838003C0C003C 0E0018070000070000070000070000FF0007C7001E07003C0700780700700700F00708F00708F0 0708F00F087817083C23900FC1E015157E9418>97 D<0E0000FE00001E00000E00000E00000E00 000E00000E00000E00000E00000E00000E00000E00000E00000E1F000E61C00E80600F00300E00 380E003C0E001C0E001E0E001E0E001E0E001E0E001E0E001E0E001E0E001C0E003C0E00380F00 700C80600C41C0083F0017237FA21B>I<01FE000703000C07801C0780380300780000700000F0 0000F00000F00000F00000F00000F00000F000007000007800403800401C00800C010007060001 F80012157E9416>I<0000E0000FE00001E00000E00000E00000E00000E00000E00000E00000E0 0000E00000E00000E00000E001F8E00704E00C02E01C01E03800E07800E07000E0F000E0F000E0 F000E0F000E0F000E0F000E0F000E07000E07800E03800E01801E00C02E0070CF001F0FE17237E A21B>I<01FC000707000C03801C01C03801C07801E07000E0F000E0FFFFE0F00000F00000F000 00F00000F000007000007800203800201C00400E008007030000FC0013157F9416>I<003C00C6 018F038F030F070007000700070007000700070007000700FFF807000700070007000700070007 000700070007000700070007000700070007000700070007807FF8102380A20F>I<0E0000FE00 001E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E1F 800E60C00E80E00F00700F00700E00700E00700E00700E00700E00700E00700E00700E00700E00 700E00700E00700E00700E00700E00700E0070FFE7FF18237FA21B>104 D<1C001E003E001E001C00000000000000000000000000000000000E00FE001E000E000E000E00 0E000E000E000E000E000E000E000E000E000E000E000E000E000E00FFC00A227FA10E>I<0E00 00FE00001E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00 000E03FC0E01F00E01C00E01800E02000E04000E08000E10000E38000EF8000F1C000E1E000E0E 000E07000E07800E03C00E01C00E01E00E00F00E00F8FFE3FE17237FA21A>107 D<0E00FE001E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E00 0E000E000E000E000E000E000E000E000E000E000E000E000E000E000E00FFE00B237FA20E>I< 0E1FC07F00FE60E183801E807201C00F003C00E00F003C00E00E003800E00E003800E00E003800 E00E003800E00E003800E00E003800E00E003800E00E003800E00E003800E00E003800E00E0038 00E00E003800E00E003800E00E003800E00E003800E0FFE3FF8FFE27157F942A>I<0E1F80FE60 C01E80E00F00700F00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00 700E00700E00700E00700E00700E0070FFE7FF18157F941B>I<01FC000707000C01801800C038 00E0700070700070F00078F00078F00078F00078F00078F00078F000787000707800F03800E01C 01C00E038007070001FC0015157F9418>I<0E1F00FE61C00E80600F00700E00380E003C0E001C 0E001E0E001E0E001E0E001E0E001E0E001E0E001E0E003C0E003C0E00380F00700E80E00E41C0 0E3F000E00000E00000E00000E00000E00000E00000E00000E00000E0000FFE000171F7F941B> I<0E3CFE461E8F0F0F0F060F000E000E000E000E000E000E000E000E000E000E000E000E000E00 0F00FFF010157F9413>114 D<0F8830786018C018C008C008E008F0007F803FE00FF001F8003C 801C800C800CC00CC008E018D0308FC00E157E9413>I<02000200020002000600060006000E00 1E003E00FFF80E000E000E000E000E000E000E000E000E000E000E000E040E040E040E040E040E 040708030801F00E1F7F9E13>I<0E0070FE07F01E00F00E00700E00700E00700E00700E00700E 00700E00700E00700E00700E00700E00700E00700E00700E00F00E00F006017003827800FC7F18 157F941B>II121 D E /Fs 17 118 df<000003000000000003 00000000000300000000000780000000000780000000000FC0000000000FC0000000000FC00000 000017E00000000013E00000000013E00000000023F00000000021F00000000021F00000000040 F80000000040F80000000040F800000000807C00000000807C00000001807E00000001003E0000 0001003E00000002003F00000002001F00000002001F00000004000F80000004000F8000000400 0F800000080007C00000080007C00000180007E000001FFFFFE000001FFFFFE00000200003F000 00200001F00000200001F00000400001F80000400000F80000400000F800008000007C00008000 007C00008000007C00010000003E00010000003E00030000003F00030000001F00070000001F00 1F8000003F80FFE00003FFFCFFE00003FFFC2E327EB132>65 D<00001FE000800000FFFC018000 07F00F0180000F80018380003E0000C38000780000278000F00000178001E000000F8003C00000 0F800780000007800780000003800F00000003801F00000001801E00000001803E00000001803C 00000001803C00000000807C00000000807C0000000080780000000000F80000000000F8000000 0000F80000000000F80000000000F80000000000F80000000000F80000000000F80000000000F8 0000000000F80000000000F800000FFFFC7800000FFFFC7C0000001FC07C0000000F803C000000 0F803C0000000F803E0000000F801E0000000F801F0000000F800F0000000F80078000000F8007 C000000F8003C000000F8001E000000F8000F000001780007C00001780003E00006380000F8000 C3800007F00781800000FFFE008000001FF000002E337CB134>71 DII<00FE00000303C0000C00E00010007000100038003C003C00 3E001C003E001E003E001E0008001E0000001E0000001E0000001E00000FFE0000FC1E0003E01E 000F801E001F001E003E001E003C001E007C001E00F8001E04F8001E04F8001E04F8003E04F800 3E0478003E047C005E043E008F080F0307F003FC03E01E1F7D9E21>97 D<003F8000E060038018 0700040F00041E001E1C003E3C003E7C003E7C0008780000F80000F80000F80000F80000F80000 F80000F80000F80000F800007800007C00007C00003C00011E00011E00020F0002070004038018 00E060003F80181F7D9E1D>99 D<000001E000003FE000003FE0000003E0000001E0000001E000 0001E0000001E0000001E0000001E0000001E0000001E0000001E0000001E0000001E0000001E0 000001E0000001E0000001E0001F81E000F061E001C019E0078005E00F0003E00E0003E01E0001 E03C0001E03C0001E07C0001E0780001E0F80001E0F80001E0F80001E0F80001E0F80001E0F800 01E0F80001E0F80001E0F80001E0780001E0780001E03C0001E03C0001E01C0001E01E0003E00E 0005E0070009E0038011F000E061FF003F81FF20327DB125>I<003F800000E0E0000380380007 003C000E001E001E001E001C000F003C000F007C000F0078000F8078000780F8000780F8000780 FFFFFF80F8000000F8000000F8000000F8000000F8000000F8000000780000007C0000003C0000 003C0000801E0000800E0001000F0002000780020001C00C0000F03000001FC000191F7E9E1D> I<07000F801F801F800F800700000000000000000000000000000000000000000000000780FF80 FF800F800780078007800780078007800780078007800780078007800780078007800780078007 800780078007800780078007800FC0FFF8FFF80D307EAF12>105 D<07800000FF800000FF8000 000F80000007800000078000000780000007800000078000000780000007800000078000000780 000007800000078000000780000007800000078000000780000007801FFC07801FFC078007E007 800780078006000780040007800800078010000780600007808000078100000783800007878000 078FC0000793C00007A1E00007C1F0000780F0000780780007807C0007803C0007803E0007801F 0007800F0007800F80078007C0078003C0078003E00FC007F8FFFC0FFFFFFC0FFF20327EB123> 107 D<0780FF80FF800F8007800780078007800780078007800780078007800780078007800780 078007800780078007800780078007800780078007800780078007800780078007800780078007 800780078007800780078007800780078007800FC0FFFCFFFC0E327EB112>I<0780FE0000FF83 078000FF8C03C0000F9001E00007A001E00007A000F00007C000F00007C000F000078000F00007 8000F000078000F000078000F000078000F000078000F000078000F000078000F000078000F000 078000F000078000F000078000F000078000F000078000F000078000F000078000F000078000F0 00078000F000078000F000078000F0000FC001F800FFFC1FFF80FFFC1FFF80211F7E9E25>110 D<001FC00000F0780001C01C00070007000F0007801E0003C01C0001C03C0001E03C0001E07800 00F0780000F0780000F0F80000F8F80000F8F80000F8F80000F8F80000F8F80000F8F80000F8F8 0000F8780000F07C0001F03C0001E03C0001E01E0003C01E0003C00F00078007800F0001C01C00 00F07800001FC0001D1F7E9E21>I<0783E0FF8C18FF907C0F907C07A07C07C03807C00007C000 07C000078000078000078000078000078000078000078000078000078000078000078000078000 0780000780000780000780000780000780000780000FC000FFFE00FFFE00161F7E9E19>114 D<01FC100E03301800F0300070600030E00030E00010E00010E00010F00010F800007E00003FF0 001FFF000FFFC003FFE0003FF00001F80000F880003C80003C80001CC0001CC0001CE0001CE000 18F00038F00030CC0060C301C080FE00161F7E9E1A>I<00400000400000400000400000400000 C00000C00000C00001C00001C00003C00007C0000FC0001FFFE0FFFFE003C00003C00003C00003 C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003 C01003C01003C01003C01003C01003C01003C01003C01001C02001E02000E0400078C0001F0014 2C7FAB19>I<078000F000FF801FF000FF801FF0000F8001F000078000F000078000F000078000 F000078000F000078000F000078000F000078000F000078000F000078000F000078000F0000780 00F000078000F000078000F000078000F000078000F000078000F000078000F000078000F00007 8000F000078001F000078001F000078001F000038002F00003C004F00001C008F800007030FF80 001FC0FF80211F7E9E25>I E end %%EndProlog %%BeginSetup %%Feature: *Resolution 300 TeXDict begin @letter /letter where {pop letter} if %%EndSetup %%Page: 1 1 bop 501 287 a Fs(A)21 b(Gen)n(tle)h(In)n(tro)r(duction)g(to)g(Hask)n(ell)432 443 y Fr(P)o(aul)16 b(Hudak)395 501 y(Y)l(ale)g(Univ)o(ersit)o(y)203 559 y(Departmen)o(t)e(of)j(Computer)e(Science)1228 443 y(Joseph)i(H.)f(F)l (asel)1145 501 y(Univ)o(ersit)o(y)e(of)i(California)1044 559 y(Los)h(Alamos)e(National)h(Lab)q(oratory)0 788 y Fq(1)69 b(In)n(tro)r (duction)0 920 y Fp(Our)20 b(purp)q(ose)h(in)f(writing)g(this)h(tutorial)e (is)i(not)e(to)g(teac)o(h)h(programming,)g(nor)f(ev)o(en)h(to)f(teac)o(h)h (functional)0 977 y(programming.)j(Rather,)17 b(it)f(is)h(in)o(tended)h(to)e (serv)o(e)g(as)g(a)h(supplemen)o(t)g(to)f(the)h(Hask)o(ell)g(Rep)q(ort)g([3)o (],)f(whic)o(h)h(is)0 1033 y(otherwise)11 b(a)g(rather)g(dense)h(tec)o (hnical)g(exp)q(osition.)20 b(Our)11 b(goal)g(is)h(to)e(pro)o(vide)i(a)f(gen) o(tle)g(in)o(tro)q(duction)i(to)d(Hask)o(ell)0 1090 y(for)k(someone)g(who)g (has)g(exp)q(erience)j(with)e(at)f(least)g(one)h(other)f(language,)g (preferably)h(a)f(functional)i(language)0 1146 y(\(ev)o(en)k(if)h(only)g(an)f (\\almost-functional")h(language)f(suc)o(h)h(as)f(ML)g(or)g(Sc)o(heme\).)35 b(If)21 b(the)f(reader)h(wishes)g(to)0 1202 y(learn)15 b(more)g(ab)q(out)g (the)g(functional)h(programming)e(st)o(yle,)h(w)o(e)f(highly)j(recommend)e (Bird)g(and)h(W)l(adler's)e(text)0 1259 y Fo(Intr)n(o)n(duction)k(to)g(F)m (unctional)f(Pr)n(o)n(gr)n(amming)g Fp([1)o(],)g(whic)o(h)i(uses)e(a)g (language)h(su\016cien)o(tly)h(similar)f(to)f(Hask)o(ell)0 1315 y(to)h(mak)o(e)g(translation)h(b)q(et)o(w)o(een)f(the)h(t)o(w)o(o)e (quite)i(easy)l(.)30 b(F)l(or)18 b(a)h(useful)g(surv)o(ey)g(of)f(functional)i (programming)0 1372 y(languages)14 b(and)g(tec)o(hniques,)h(including)h(some) e(of)f(the)h(language)g(design)h(principals)h(used)e(in)h(Hask)o(ell,)f(see)g ([2].)71 1457 y(Our)j(general)g(strategy)f(for)g(in)o(tro)q(ducing)i (language)f(features)g(is)g(this:)24 b(motiv)m(ate)17 b(the)g(idea,)g (de\014ne)h(some)0 1514 y(terms,)12 b(giv)o(e)i(some)e(examples,)i(and)f (then)g(p)q(oin)o(t)g(to)g(the)g(Rep)q(ort)g(for)f(details.)20 b(W)l(e)13 b(suggest,)g(ho)o(w)o(ev)o(er,)f(that)g(the)0 1570 y(reader)17 b(completely)h(ignore)f(the)g(details)g(un)o(til)h(this)f(do)q (cumen)o(t)g(has)g(b)q(een)h(completely)g(read.)24 b(On)18 b(the)e(other)0 1627 y(hand,)g(Hask)o(ell's)h(Standard)f(Prelude)i(\(in)e (App)q(endix)i(A)f(of)e(the)i(Rep)q(ort\))f(con)o(tains)g(lots)g(of)g(useful) h(examples)0 1683 y(of)h(Hask)o(ell)h(co)q(de;)i(w)o(e)d(encourage)g(a)h (thorough)e(reading)i(once)g(this)g(tutorial)g(is)g(completed.)30 b(This)19 b(will)h(not)0 1740 y(only)d(giv)o(e)g(the)f(reader)h(a)f(feel)i (for)d(what)h(real)h(Hask)o(ell)h(co)q(de)f(lo)q(oks)g(lik)o(e,)g(but)g(will) h(also)e(familiarize)j(her)e(with)0 1796 y(Hask)o(ell's)f(standard)e(set)h (of)g(prede\014ned)i(functions)f(and)f(t)o(yp)q(es.)71 1882 y([W)l(e)e(ha)o(v)o(e)g(also)h(tak)o(en)f(the)h(course)g(of)f(not)g(la)o (ying)h(out)g(a)f(plethora)h(of)f(lexical)j(syn)o(tax)d(rules)h(at)f(the)h (outset.)0 1938 y(Rather,)i(w)o(e)g(in)o(tro)q(duce)h(them)f(incremen)o (tally)i(as)e(our)f(examples)i(demand,)g(and)f(enclose)h(them)f(in)h(brac)o (k)o(ets,)0 1995 y(as)f(with)i(this)f(paragraph.)24 b(This)18 b(is)f(in)h(stark)e(con)o(trast)f(to)h(the)h(organization)g(of)g(the)g(Rep)q (ort,)g(although)g(the)0 2051 y(Rep)q(ort)h(remains)g(the)f(authoritativ)o(e) g(source)h(for)e(details)j(\(references)e(suc)o(h)h(as)f(\\)p Fn(x)p Fp(2.1")f(refer)h(to)g(sections)h(in)0 2107 y(the)d(Rep)q(ort\).])71 2193 y(Hask)o(ell)g(is)h(a)e Fo(typ)n(eful)h Fp(programming)f(language:)922 2177 y Fm(1)962 2193 y Fp(T)o(yp)q(es)h(are)f(p)q(erv)m(asiv)o(e,)i(and)f (the)g(new)o(comer)f(is)i(b)q(est)f(o\013)0 2249 y(b)q(ecoming)f(w)o(ell-a)o (w)o(are)e(of)h(the)f(full)i(p)q(o)o(w)o(er)f(and)f(complexit)o(y)i(of)e (Hask)o(ell's)h(t)o(yp)q(e)g(system)f(from)g(the)h(outset.)19 b(F)l(or)0 2306 y(those)12 b(whose)g(only)g(exp)q(erience)i(is)f(with)f (relativ)o(ely)h(\\un)o(t)o(yp)q(eful")g(languages)f(suc)o(h)g(as)g(Basic)g (or)g(Lisp,)h(this)g(ma)o(y)0 2362 y(b)q(e)f(a)e(di\016cult)i(adjustmen)o(t;) g(for)e(those)h(familiar)g(with)h(P)o(ascal,)f(Mo)q(dula,)h(or)e(ev)o(en)h (ML,)g(the)g(adjustmen)o(t)f(should)0 2419 y(b)q(e)19 b(easier)h(but)e(still) j(not)d(insigni\014can)o(t,)j(since)f(Hask)o(ell's)f(t)o(yp)q(e)g(system)f (is)i(di\013eren)o(t)f(and)f(somewhat)g(ric)o(her)0 2475 y(than)g(most.)29 b(In)19 b(an)o(y)g(case,)g(\\t)o(yp)q(eful)g(programming")e(is)i(part)f(of)g (the)h(Hask)o(ell)g(programming)f(exp)q(erience,)0 2532 y(and)d(cannot)g(b)q (e)h(a)o(v)o(oided.)p 0 2571 780 2 v 52 2598 a Fl(1)69 2614 y Fk(A)d(phrase)h(due)f(to)g(Luca)g(Cardelli.)940 2738 y Fp(T-1)p eop %%Page: 2 2 bop 0 -40 a Fp(T-2)906 b Fj(2)45 b(V)-5 b(ALUES,)16 b(TYPES,)e(AND)h(OTHER)h (GOODIES)0 105 y Fq(2)69 b(V)-6 b(alues,)23 b(T)n(yp)r(es,)g(and)g(Other)g (Go)r(o)r(dies)0 228 y Fp(Because)g(Hask)o(ell)g(is)f(a)g(purely)i (functional)f(language,)h(all)f(computations)f(are)g(done)g(via)g(the)h(ev)m (aluation)0 285 y(of)18 b Fo(expr)n(essions)e Fp(\(syn)o(tactic)i(terms\))f (to)g(yield)j Fo(values)e Fp(\(abstract)f(en)o(tities)h(that)g(w)o(e)g (regard)f(as)h(answ)o(ers\).)27 b(In)0 341 y(particular,)12 b(there)g(are)f(no)g Fo(c)n(ommands)g Fp(that)f(op)q(erate)h(b)o(y)g (implicit)j(side)e(e\013ects)f(to)g(a)g(global)h(store.)17 b(In)12 b(addition,)0 398 y(ev)o(ery)j(v)m(alue)g(has)g(an)f(asso)q(ciated)h Fo(typ)n(e)p Fp(.)20 b(\(In)o(tuitiv)o(ely)l(,)c(w)o(e)e(can)h(think)g(of)g (t)o(yp)q(es)f(as)g(sets)h(of)f(v)m(alues.\))20 b(Examples)0 454 y(of)f(expressions)g(include)j(atomic)c(v)m(alues)j(suc)o(h)e(as)g(the)g (in)o(teger)g Fi(5)p Fp(,)g(the)g(c)o(haracter)f Fi('a')p Fp(,)i(and)f(the)g (successor)0 511 y(function)d Fi(succ)o Fp(,)f(as)g(w)o(ell)h(as)f (structured)g(v)m(alues)i(suc)o(h)e(as)g(the)g(list)h Fi([1,2,3])e Fp(and)i(the)f(pair)h Fi(\('b',4\))o Fp(.)71 589 y(Just)f(as)h(expressions)g (denote)g(v)m(alues,)h Fo(typ)n(e)f(expr)n(essions)f Fp(are)g(syn)o(tactic)h (terms)f(that)g(denote)h Fo(typ)n(e)g(values)0 645 y Fp(\(or)10 b(just)h Fo(typ)n(es)p Fp(\).)18 b(Examples)11 b(of)g(t)o(yp)q(e)g (expressions)h(include)i(the)d(atomic)g(t)o(yp)q(es)g Fi(Int)f Fp(\(\014xed-precision)k(in)o(tegers\),)0 702 y Fi(Char)h Fp(\(ascii)h(c)o (haracters\),)d Fi(Int->Int)h Fp(\(functions)i(mapping)g Fi(Int)f Fp(to)f Fi(Int)p Fp(\),)h(as)f(w)o(ell)j(as)d(the)i(structured)f(t)o(yp)q(es) 0 758 y Fi([Int])f Fp(\(homogeneous)h(lists)h(of)f(in)o(tegers\))g(and)g Fi(\(Char,Int\))f Fp(\(c)o(haracter/in)o(teger)g(pairs\).)71 837 y(All)h(Hask)o(ell)g(v)m(alues)g(are)f(\\\014rst-class"|they)g(ma)o(y)g (b)q(e)g(passed)h(as)e(argumen)o(ts)h(to)f(functions,)i(returned)f(as)0 893 y(results,)i(placed)g(in)h(data)e(structures,)g(etc.)21 b(Hask)o(ell)16 b(t)o(yp)q(es,)g(on)f(the)h(other)f(hand,)h(are)f Fo(not)h Fp(\014rst-class.)21 b(T)o(yp)q(es)0 949 y(in)16 b(a)e(sense)h Fo(describ)n(e)f Fp(v)m(alues,)i(and)f(the)f(asso)q(ciation)i(of)e(a)g(v)m (alue)i(with)f(its)g(t)o(yp)q(e)g(is)g(called)i(a)d Fo(typing)p Fp(.)20 b(Using)15 b(the)0 1006 y(examples)h(of)f(v)m(alues)h(and)f(t)o(yp)q (es)h(ab)q(o)o(v)o(e,)e(w)o(e)h(write)g(t)o(ypings)h(as)e(follo)o(ws:)691 1115 y Fi(5)48 b(::)23 b(Int)667 1171 y('a')h(::)f(Char)643 1228 y(succ)h(::)f(Int)h(->)f(Int)572 1284 y([1,2,3])g(::)g([Int])572 1341 y(\('b',4\))g(::)g(\(Char,Int\))0 1450 y Fp(The)15 b Fi(::)g Fp(can)h(b)q(e)g(read)f(\\has)f(t)o(yp)q(e.")71 1528 y(F)l(unctions)i(in)h (Hask)o(ell)g(are)f(normally)h(de\014ned)h(b)o(y)e(a)f(series)i(of)f Fo(e)n(quations)p Fp(.)22 b(F)l(or)16 b(example,)h(the)f(successor)0 1585 y(function)g Fi(succ)f Fp(can)g(b)q(e)h(de\014ned)g(b)o(y)g(the)f (single)h(equation:)71 1694 y Fi(succ)23 b(n)238 b(=)24 b(n+1)0 1803 y Fp(An)16 b(equation)g(is)g(an)g(example)h(of)e(a)g Fo(de)n(clar)n (ation)p Fp(.)21 b(Another)16 b(kind)h(of)e(declaration)i(is)f(a)f Fo(typ)n(e)i(signatur)n(e)f(de)n(cla-)0 1859 y(r)n(ation)f Fp(\()p Fn(x)p Fp(4.4.1\),)e(with)i(whic)o(h)h(w)o(e)f(can)h(declare)g(an)f (explicit)i(t)o(yping)f(for)e Fi(succ)p Fp(:)71 1971 y Fi(succ)285 b(::)24 b(Int)f(->)h(Int)0 2080 y Fp(W)l(e)15 b(will)i(ha)o(v)o(e)e(m)o(uc)o (h)g(more)g(to)f(sa)o(y)h(ab)q(out)g(function)h(de\014nitions)h(in)f(Section) g(3.)71 2158 y(F)l(or)i(p)q(edagogical)i(purp)q(oses,)g(when)g(w)o(e)f(wish)h (to)e(indicate)j(that)d(an)h(expression)h Fh(e)1562 2165 y Fm(1)1601 2158 y Fp(ev)m(aluates,)h(or)d(\\re-)0 2214 y(duces,")d(to)g (another)g(expression)h(or)e(v)m(alue)j Fh(e)795 2221 y Fm(2)815 2214 y Fp(,)e(w)o(e)f(will)j(write:)838 2307 y Fh(e)859 2314 y Fm(1)952 2307 y Fn(\))74 b Fh(e)1092 2314 y Fm(2)0 2400 y Fp(F)l(or)15 b(example,)g(note)g(that:)712 2457 y Fi(succ)23 b(\(succ)g(3\))73 b Fn(\))h Fi(5)71 2557 y Fp(Hask)o(ell's)17 b Fo(static)h(typ)n(e)h(system)d Fp(de\014nes)j(the)e(formal)g(relationship)i (b)q(et)o(w)o(een)f(t)o(yp)q(es)f(and)h(v)m(alues)g(\()p Fn(x)p Fp(4.1.3\).)0 2614 y(The)11 b(static)f(t)o(yp)q(e)h(system)f(ensures)i(that)d (Hask)o(ell)j(programs)d(are)i Fo(typ)n(e)h(safe)p Fp(;)f(that)f(is,)i(that)e (the)h(programmer)e(has)p eop %%Page: 3 3 bop 0 -40 a Fj(2.1)45 b(P)o(olymorphic)15 b(T)o(yp)q(es)1390 b Fp(T-3)0 105 y(not)13 b(mismatc)o(hed)h(t)o(yp)q(es)f(in)h(some)f(w)o(a)o (y)l(.)19 b(F)l(or)12 b(example,)i(w)o(e)f(cannot)h(generally)g(add)g (together)e(t)o(w)o(o)g(c)o(haracters,)0 162 y(so)17 b(the)g(expression)h Fi('a'+'b')d Fp(is)j(ill-t)o(yp)q(ed.)28 b(The)17 b(main)g(adv)m(an)o(tage)g (of)f(statically)i(t)o(yp)q(ed)f(languages)g(is)h(w)o(ell-)0 218 y(kno)o(wn:)g(All)c(t)o(yp)q(e)e(errors)g(are)g(detected)h(at)f (compile-time.)21 b(This)13 b(not)f(only)g(aids)h(the)g(user)f(in)i (reasoning)e(ab)q(out)0 274 y(programs,)17 b(but)h(also)g(p)q(ermits)g(a)f (compiler)j(to)d(generate)g(more)h(e\016cien)o(t)g(co)q(de)h(\(for)d (example,)j(no)f(run-time)0 331 y(t)o(yp)q(e)d(tags)f(or)h(tests)g(are)g (required\).)71 410 y(The)h(t)o(yp)q(e)g(system)f(also)h(ensures)h(that)e (user-supplied)k(t)o(yp)q(e)d(signatures)g(are)g(correct.)22 b(In)16 b(fact,)g(Hask)o(ell's)0 467 y(t)o(yp)q(e)h(system)f(is)h(p)q(o)o(w)o (erful)g(enough)g(to)f(allo)o(w)h(us)f(to)g(a)o(v)o(oid)h(writing)g(an)o(y)f (t)o(yp)q(e)h(signatures)f(at)g(all,)1743 450 y Fm(2)1781 467 y Fp(in)h(whic)o(h)0 523 y(case)d(w)o(e)h(sa)o(y)e(that)h(the)h(t)o(yp)q(e)f (system)g Fo(infers)g Fp(the)g(correct)g(t)o(yp)q(es)h(for)e(us.)20 b(Nev)o(ertheless,)15 b(judicious)h(placemen)o(t)0 580 y(of)f(t)o(yp)q(e)g (signatures)g(is)h(a)f(go)q(o)q(d)g(idea,)h(as)e(w)o(e)h(did)i(for)d Fi(succ)p Fp(,)g(since)j(it)e(impro)o(v)o(es)g(readabilit)o(y)i(and)e(helps)h (bring)0 636 y(programming)f(errors)f(to)h(ligh)o(t.)71 715 y([The)e(reader)g(will)j(note)d(that)g(w)o(e)g(ha)o(v)o(e)g(capitalized)j (iden)o(ti\014ers)f(that)e(denote)g(sp)q(eci\014c)j(t)o(yp)q(es,)d(suc)o(h)h (as)f Fi(Int)0 772 y Fp(and)18 b Fi(Char)o Fp(,)g(but)g(not)g(iden)o (ti\014ers)h(that)e(denote)h(v)m(alues,)h(suc)o(h)f(as)g Fi(succ)o Fp(.)28 b(This)18 b(is)g(not)g(just)f(a)h(con)o(v)o(en)o(tion:)25 b(it)0 828 y(is)16 b(enforced)g(b)o(y)g(Hask)o(ell's)g(lexical)i(syn)o(tax.)i (In)c(fact,)f(the)h(case)f(of)h(the)f(other)h(c)o(haracters)e(matters,)h(to)q (o:)20 b Fi(foo)o Fp(,)0 885 y Fi(fOo)p Fp(,)14 b(and)i Fi(fOO)e Fp(are)h(all)i(distinct)f(iden)o(ti\014ers.])0 1028 y Fg(2.1)56 b(P)n(olymorphic)17 b(T)n(yp)r(es)0 1137 y Fp(Hask)o(ell)k(also)g(incorp)q (orates)f Fo(p)n(olymorphic)h Fp(t)o(yp)q(es|t)o(yp)q(es)g(that)f(are)g(univ) o(ersally)i(quan)o(ti\014ed)g(in)f(some)f(w)o(a)o(y)0 1194 y(o)o(v)o(er)d Fo(al)r(l)g Fp(t)o(yp)q(es.)27 b(P)o(olymorphic)18 b(t)o(yp)q(e)f(expressions)i(essen)o(tially)g(describ)q(e)g Fo(families)e Fp(of)g(t)o(yp)q(es.)27 b(F)l(or)16 b(example,)0 1250 y(\()p Fn(8)p Fi(a)p Fp(\))p Fi([a])21 b Fp(is)h(the)g(family)h(of)f(t)o (yp)q(es)f(consisting)i(of,)g(for)e(ev)o(ery)h(t)o(yp)q(e)g Fi(a)p Fp(,)h(the)f(t)o(yp)q(e)g(of)g(lists)h(of)e Fi(a)p Fp(.)40 b(Lists)22 b(of)0 1306 y(in)o(tegers)15 b(\(e.g.)f Fi([1,2,3])o Fp(\),)g(lists)i(of)f(c)o(haracters)f(\()p Fi(['a','b','c'])n Fp(\),)g(ev)o(en)h(lists)h(of)f(lists)h(of)e(in)o(tegers,)h(etc.,)f(are)0 1363 y(all)j(mem)o(b)q(ers)e(of)h(this)g(family)l(.)22 b(\(Note,)15 b(ho)o(w)o(ev)o(er,)f(that)h Fi([2,'b'])g Fp(is)h Fo(not)f Fp(a)h(v)m(alid)h(example,)f(since)h(there)f(is)g(no)0 1419 y(single)h(t)o(yp)q(e)e(that)f(con)o(tains)i(b)q(oth)f Fi(2)g Fp(and)g Fi('b')p Fp(.\))71 1499 y([Iden)o(ti\014ers)21 b(suc)o(h)f(as)44 b Fi(a)g Fp(ab)q(o)o(v)o(e)20 b(are)g(called)i Fo(typ)n(e)f(variables)p Fp(,)g(and)f(are)g(uncapitalized)j(to)d(distinguish)0 1555 y(them)d(from)g(sp)q(eci\014c)i(t)o(yp)q(es)f(suc)o(h)f(as)g Fi(Int)p Fp(.)26 b(F)l(urthermore,)17 b(since)i(Hask)o(ell)f(has)f(only)h (univ)o(ersally)h(quan)o(ti\014ed)0 1612 y(t)o(yp)q(es,)c(there)g(is)h(no)f (need)h(to)f(explicitly)j(write)d(out)g(the)g(sym)o(b)q(ol)g(for)g(univ)o (ersal)h(quan)o(ti\014cation,)g(and)f(th)o(us)g(w)o(e)0 1668 y(simply)g(write)f Fi([a])f Fp(in)i(the)f(example)g(ab)q(o)o(v)o(e.)19 b(In)c(other)e(w)o(ords,)g(all)i(t)o(yp)q(e)f(v)m(ariables)h(are)e (implicitly)k(univ)o(ersally)0 1725 y(quan)o(ti\014ed.])71 1804 y(Lists)g(are)g(a)g(commonly)h(used)g(data)e(structure)i(in)g (functional)g(languages,)g(and)f(are)g(a)g(go)q(o)q(d)g(v)o(ehicle)j(for)0 1860 y(explaining)f(the)e(principals)j(of)c(p)q(olymorphism.)27 b(The)17 b(list)h Fi([1,2,3])e Fp(in)i(Hask)o(ell)f(is)h(actually)g (shorthand)f(for)0 1917 y(the)i(list)g Fi(1:\(2:\(3:[]\)\))o Fp(,)g(where)g Fi([])f Fp(is)i(the)e(empt)o(y)h(list)g(and)g Fi(:)g Fp(is)g(the)g(in\014x)h(op)q(erator)e(that)g(adds)g(its)h(\014rst)0 1973 y(argumen)o(t)f(to)g(the)h(fron)o(t)f(of)h(its)g(second)g(argumen)o(t)f (\(a)g(list\).)1093 1957 y Fm(3)1145 1973 y Fp(Since)i Fi(:)f Fp(is)g(righ)o(t)g(asso)q(ciativ)o(e,)g(w)o(e)g(can)g(also)0 2030 y(write)c(this)h(list)g(as)f Fi(1:2:3:[])o Fp(.)71 2109 y(As)c(an)h(example)g(of)f(a)h(user-de\014ned)h(function)f(that)f(op)q (erates)h(on)f(lists,)i(consider)f(the)g(problem)g(of)g(coun)o(ting)0 2165 y(the)j(n)o(um)o(b)q(er)h(of)f(elemen)o(ts)g(in)h(a)f(list:)71 2266 y Fi(length)428 b(::)24 b([a])f(->)h(Int)71 2322 y(length)46 b([])334 b(=)24 b(0)71 2379 y(length)f(\(x:xs\))261 b(=)24 b(1)g(+)f(length)h(xs)0 2488 y Fp(This)14 b(de\014nition)i(is)e(almost)g (self-explanatory)l(.)20 b(W)l(e)14 b(can)g(read)g(the)g(equations)g(as)f(sa) o(ying:)19 b(\\The)14 b(length)g(of)g(the)p 0 2525 780 2 v 52 2552 a Fl(2)69 2568 y Fk(With)g(a)f(few)g(exceptions)i(to)d(b)q(e)i (describ)q(ed)h(later.)52 2598 y Fl(3)69 2614 y Ff(:)e Fk(and)g Ff([])f Fk(are)h(lik)o(e)i(Lisp's)e Ff(cons)f Fk(and)h Ff(nil)o Fk(,)g(resp)q(ectiv)o(ely)m(.)p eop %%Page: 4 4 bop 0 -40 a Fp(T-4)906 b Fj(2)45 b(V)-5 b(ALUES,)16 b(TYPES,)e(AND)h(OTHER)h (GOODIES)0 105 y Fp(empt)o(y)g(list)i(is)f(0,)f(and)h(the)g(length)g(of)f(a)h (list)g(whose)g(\014rst)f(elemen)o(t)h(is)h Fi(x)e Fp(and)h(remainder)g(is)g Fi(xs)g Fp(is)g(1)f(plus)i(the)0 162 y(length)g(of)f Fi(xs)p Fp(.")26 b(\(Note)16 b(the)i(naming)f(con)o(v)o(en)o(tion)h(used)g(here;)g Fi(xs)f Fp(is)h(the)f(plural)i(of)e Fi(x)p Fp(,)g(and)h(should)g(b)q(e)g (read)0 218 y(that)c(w)o(a)o(y)l(.\))71 300 y(Although)20 b(in)o(tuitiv)o(e,) h(this)f(example)g(highligh)o(ts)h(an)e(imp)q(ortan)o(t)g(asp)q(ect)h(of)f (Hask)o(ell)h(that)f(is)h(y)o(et)f(to)f(b)q(e)0 357 y(explained:)k Fo(p)n(attern)17 b(matching)p Fp(.)j(The)15 b(left-hand)i(sides)f(of)f(the)g (equations)h(con)o(tain)f Fo(p)n(atterns)g Fp(suc)o(h)h(as)f Fi([])g Fp(and)0 413 y Fi(x:xs)o Fp(.)28 b(In)19 b(a)e(function)i (application)g(these)f(patterns)g(are)f Fo(matche)n(d)i Fp(against)e(actual)h (parameters)f(in)i(a)e(fairly)0 469 y(in)o(tuitiv)o(e)c(w)o(a)o(y)d(\()p Fi([])h Fp(only)h(matc)o(hes)f(the)h(empt)o(y)f(list,)i(and)e Fi(x:xs)g Fp(will)i(successfully)h(matc)o(h)d(an)o(y)g(list)h(with)g(at)f (least)0 526 y(one)17 b(elemen)o(t,)g(binding)i Fi(x)d Fp(to)g(the)h(\014rst) f(elemen)o(t)i(and)e Fi(xs)h Fp(to)f(the)h(rest)f(of)g(the)h(list\).)24 b(If)17 b(the)g(matc)o(h)f(succeeds,)0 582 y(the)h(righ)o(t-hand)g(side)g(is) h(ev)m(aluated)f(and)g(returned)g(as)f(the)h(result)g(of)f(the)h (application.)26 b(If)17 b(it)g(fails,)g(the)g(next)0 639 y(equation)f(is)f (tried,)h(and)f(if)h(all)g(equations)f(fail,)h(an)f(error)g(results.)71 721 y(De\014ning)e(functions)g(b)o(y)f(pattern)f(matc)o(hing)i(is)f(quite)h (common)f(in)h(Hask)o(ell,)g(and)g(the)f(user)g(should)h(b)q(ecome)0 777 y(familiar)j(with)g(the)f(v)m(arious)h(kinds)g(of)f(patterns)g(that)g (are)g(allo)o(w)o(ed;)g(w)o(e)g(will)i(return)e(to)g(this)h(issue)g(in)g (Section)0 834 y(3.14.)71 916 y Fi(length)i Fp(is)i(also)f(an)g(example)i(of) e(a)g Fo(p)n(olymorphic)h(function)p Fp(.)32 b(It)20 b(can)f(b)q(e)h(applied) h(to)e(a)g(list)h(con)o(taining)0 972 y(elemen)o(ts)c(of)f(an)o(y)f(t)o(yp)q (e.)20 b(F)l(or)15 b(example:)600 1071 y Fi(length)23 b([1,2,3])245 b Fn(\))102 b Fp(3)600 1128 y Fi(length)23 b(['a','b','c'])101 b Fn(\))h Fp(3)600 1184 y Fi(length)23 b([[],[],[]])173 b Fn(\))102 b Fp(3)71 1309 y(Here)15 b(are)g(t)o(w)o(o)f(other)h(useful)h(p)q(olymorphic) h(functions)f(on)f(lists)h(that)e(will)j(b)q(e)f(used)g(later:)71 1418 y Fi(head)476 b(::)24 b([a])f(->)h(a)71 1475 y(head)f(\(x:xs\))309 b(=)48 b(x)71 1554 y(tail)476 b(::)24 b([a])f(->)h([a])71 1611 y(tail)f(\(x:xs\))309 b(=)48 b(xs)71 1770 y Fp(With)10 b(p)q(olymorphic)i(t)o (yp)q(es,)g(w)o(e)e(\014nd)h(that)f(some)g(t)o(yp)q(es)h(are)f(in)h(a)g (sense)g(strictly)g Fo(mor)n(e)h(gener)n(al)d Fp(than)i(others.)0 1827 y(F)l(or)18 b(example,)h(the)f(t)o(yp)q(e)h Fi([a])e Fp(is)i(more)f (general)h(than)f Fi([Char])o Fp(.)29 b(In)19 b(other)f(w)o(ords,)f(the)i (latter)f(t)o(yp)q(e)g(can)g(b)q(e)0 1883 y(deriv)o(ed)12 b(from)e(the)h (former)f(b)o(y)h(a)g(suitable)h(substitution)g(for)e Fi(a)p Fp(.)18 b(With)12 b(regard)e(to)g(this)i(generalization)g(ordering,)0 1940 y(Hask)o(ell's)21 b(t)o(yp)q(e)g(system)g(p)q(ossesses)g(t)o(w)o(o)e (imp)q(ortan)o(t)h(prop)q(erties:)32 b(First,)22 b(ev)o(ery)e(w)o(ell-t)o(yp) q(ed)j(expression)e(is)0 1996 y(guaran)o(teed)16 b(to)f(ha)o(v)o(e)h(a)g (unique)i Fo(princip)n(al)d Fp(t)o(yp)q(e)i(\(explained)g(b)q(elo)o(w\),)g (and)f(second,)h(the)f(principal)j(t)o(yp)q(e)d(can)0 2053 y(b)q(e)k Fo(inferr)n(e)n(d)f Fp(automatically)h(\()p Fn(x)o Fp(4.1.3\).)31 b(In)20 b(comparison)g(to)f(a)g Fo(monomorphic)n(al)r(ly)i (typ)n(e)n(d)e Fp(language)h(suc)o(h)f(as)0 2109 y(P)o(ascal,)c(the)h(reader) g(will)i(\014nd)e(that)f Fo(p)n(olymorphism)i Fp(impro)o(v)o(es)e(expressiv)o (eness,)i(and)f Fo(typ)n(e)h(infer)n(enc)n(e)d Fp(lessens)0 2166 y(the)h(burden)h(of)f(t)o(yp)q(es)g(on)h(the)f(programmer.)71 2248 y(An)f(expression's)h(or)e(function's)i(principal)h(t)o(yp)q(e)f(is)f (the)g(least)h(general)f(t)o(yp)q(e)h(that,)e(in)o(tuitiv)o(ely)l(,)j(\\con)o (tains)0 2304 y(all)22 b(instances)f(of)f(the)h(expression.")37 b(F)l(or)20 b(example,)j(the)e(principal)i(t)o(yp)q(e)d(of)h Fi(head)f Fp(is)h Fi([a]->a)o Fp(;)i(the)e(t)o(yp)q(es)0 2361 y Fi([b]->a)o Fp(,)15 b Fi(a->a)o Fp(,)f(or)g(ev)o(en)39 b Fi(a)g Fp(are)14 b Fo(to)n(o)i(gener)n(al)p Fp(,)d(whereas)i(something)g(lik) o(e)g Fi([Int]->Int)f Fp(is)h Fo(to)n(o)h(sp)n(e)n(ci\014c)p Fp(.)i(The)0 2417 y(existence)c(of)e(unique)h(principal)i(t)o(yp)q(es)d(is)h (the)g(hallmark)g(feature)f(of)g(the)g Fo(Hind)r(ley-Milner)h(typ)n(e)g (system)p Fp(,)f(whic)o(h)0 2473 y(forms)g(the)g(basis)h(of)f(the)h(t)o(yp)q (e)f(systems)g(of)g(Hask)o(ell,)h(ML,)g(Miranda,)1191 2457 y Fm(4)1223 2473 y Fp(and)g(sev)o(eral)f(other)g(\(mostly)g(functional\))0 2530 y(languages.)p 0 2571 780 2 v 52 2598 a Fl(4)69 2614 y Fk(\\Miranda")j(is)f(a)f(trademark)h(of)e(Researc)o(h)i(Soft)o(w)o(are,)f (Ltd.)p eop %%Page: 5 5 bop 0 -40 a Fj(2.2)45 b(User-De\014ned)16 b(T)o(yp)q(es)1384 b Fp(T-5)0 105 y Fg(2.2)56 b(User-De\014ned)17 b(T)n(yp)r(es)0 217 y Fp(W)l(e)f(can)h(de\014ne)g(our)f(o)o(wn)f(t)o(yp)q(es)i(in)g(Hask)o (ell)g(using)g(a)f Fi(data)f Fp(declaration,)i(whic)o(h)g(w)o(e)f(in)o(tro)q (duce)h(via)f(a)g(series)0 273 y(of)f(examples)h(\()p Fn(x)p Fp(4.2.1\).)71 355 y(An)f(imp)q(ortan)o(t)g(prede\014ned)i(t)o(yp)q(e)e(in)h (Hask)o(ell)g(is)g(that)e(of)h(truth)g(v)m(alues:)71 464 y Fi(data)23 b(Bool)357 b(=)24 b(False)f(|)h(True)0 573 y Fp(The)17 b(t)o(yp)q(e)h(b)q(eing)g(de\014ned)h(here)e(is)h Fi(Bool)o Fp(,)g(and)f(it)g(has)g(exactly)h(t)o(w)o(o)e(v)m(alues:)25 b Fi(True)16 b Fp(and)i Fi(False)o Fp(.)26 b Fi(Bool)16 b Fp(is)i(an)0 630 y(example)g(of)e(a)h(\(n)o(ullary\))g Fo(typ)n(e)h(c)n(onstructor)p Fp(,)f(and)h Fi(True)e Fp(and)h Fi(False)g Fp(are)f(\(also)h(n)o(ullary\))h Fo(data)g(c)n(onstructors)0 686 y Fp(\(or)c(just)h Fo(c)n(onstructors)p Fp(,)g(for)f(short\).)71 768 y(Similarly)l(,)j(w)o(e)e(migh)o(t)g(wish)g(to)g (de\014ne)h(a)f(color)g(t)o(yp)q(e:)71 877 y Fi(data)23 b(Color)333 b(=)24 b(Red)f(|)h(Green)f(|)h(Blue)f(|)h(Indigo)f(|)h(Violet)0 986 y Fp(Both)18 b Fi(Bool)f Fp(and)h Fi(Color)f Fp(are)g(examples)i(of)e Fo(enumer)n(ate)n(d)h(typ)n(es)p Fp(,)g(since)h(they)f(consist)g(of)f(a)h (\014nite)g(n)o(um)o(b)q(er)g(of)0 1043 y(n)o(ullary)e(data)f(constructors.) 71 1125 y(Here)g(is)h(an)f(example)h(of)f(a)g(t)o(yp)q(e)g(with)g(just)g(one) h(data)e(constructor:)71 1234 y Fi(data)23 b(Point)g(a)286 b(=)24 b(Pt)g(a)f(a)0 1343 y Fp(Because)13 b(of)g(the)g(single)h (constructor,)e(a)g(t)o(yp)q(e)h(lik)o(e)h Fi(Point)e Fp(is)i(often)e(called) j(a)d Fo(tuple)i(typ)n(e)p Fp(,)f(since)h(it)f(is)g(essen)o(tially)0 1399 y(just)h(a)h(cartesian)f(pro)q(duct)h(\(in)g(this)g(case)g(binary\))g (of)f(other)g(t)o(yp)q(es.)1189 1383 y Fm(5)1228 1399 y Fp(In)i(con)o(trast,) d(m)o(ulti-constructor)h(t)o(yp)q(es,)0 1456 y(suc)o(h)i(as)e Fi(Bool)h Fp(and)g Fi(Color)p Fp(,)f(are)h(called)i(\(disjoin)o(t\))e Fo(union)g Fp(t)o(yp)q(es.)71 1538 y(More)c(imp)q(ortan)o(tly)l(,)h(ho)o(w)o (ev)o(er,)f Fi(Point)g Fp(is)i(an)e(example)i(of)e(a)h Fo(p)n(olymorphic)g Fp(t)o(yp)q(e:)18 b(for)11 b(an)o(y)h(t)o(yp)q(e)f Fh(t)p Fp(,)i(it)f (de\014nes)0 1594 y(the)17 b(t)o(yp)q(e)h(of)f(cartesian)g(p)q(oin)o(ts)h (that)f(use)g Fh(t)h Fp(as)f(the)h(co)q(ordinate)f(t)o(yp)q(e.)27 b Fi(Point)17 b Fp(can)g(no)o(w)g(b)q(e)h(seen)g(clearly)g(as)0 1651 y(a)g(unary)g(t)o(yp)q(e)g(constructor,)f(since)j(from)d(the)h(t)o(yp)q (e)g Fh(t)h Fp(it)f(constructs)g(a)f(new)i(t)o(yp)q(e)f Fi(Point)23 b Fh(t)p Fp(.)29 b(\(In)18 b(the)g(same)0 1707 y(sense,)e(using)h(the)f(list) h(example)g(giv)o(en)g(earlier,)g Fi([)p 884 1707 14 2 v 16 w(])f Fp(is)h(also)f(a)f(t)o(yp)q(e)i(constructor)e(\(where)h(w)o(e)g(ha)o(v) o(e)f(used)i(\\)p 1914 1707 V 16 w(")0 1764 y(to)g(denote)i(the)f(missing)h (argumen)o(t\):)24 b(giv)o(en)19 b(an)o(y)f(t)o(yp)q(e)g Fh(t)g Fp(w)o(e)g(can)g(\\apply")h Fi([)p 1404 1764 V 16 w(])f Fp(to)f(yield)j(a)e (new)g(t)o(yp)q(e)g Fi([)p Fh(t)p Fi(])p Fp(.)0 1820 y(Similarly)l(,)p 203 1820 V 32 w Fi(->)p 267 1820 V 28 w Fp(is)c(a)e(t)o(yp)q(e)h (constructor:)18 b(giv)o(en)13 b(t)o(w)o(o)f(t)o(yp)q(es)g Fh(t)i Fp(and)f Fh(u)p Fp(,)f Fh(t)p Fi(->)q Fh(u)g Fp(is)i(the)f(t)o(yp)q(e) f(of)h(functions)g(mapping)0 1876 y(elemen)o(ts)j(of)f(t)o(yp)q(e)g Fh(t)g Fp(to)g(elemen)o(ts)h(of)f(t)o(yp)q(e)g Fh(u)p Fp(.\))71 1958 y(Note)f(that)g(the)g(t)o(yp)q(e)h(of)f(the)h(binary)g(constructor)f Fi(Pt)g Fp(is)h Fi(a)24 b(->)g(a)f(->)h(Point)f(a)p Fp(,)14 b(and)h(th)o(us)g(the)f(follo)o(wing)0 2015 y(t)o(ypings)h(are)g(v)m(alid:)71 2124 y Fi(Pt)47 b(2.0)g(3.0)286 b(::)24 b(Point)f(Float)71 2180 y(Pt)47 b('a')g('b')286 b(::)24 b(Point)f(Char)71 2237 y(Pt)g(True)g(False)262 b(::)24 b(Point)f(Bool)0 2346 y Fp(On)16 b(the)f(other)g(hand,)g(an)g(expression)h(suc)o(h)g(as)f Fi(Pt)23 b('a')h(1)15 b Fp(is)g(ill-t)o(yp)q(ed.)71 2428 y(It)h(is)h(imp)q(ortan)o(t)f (to)g(distinguish)i(b)q(et)o(w)o(een)f(applying)g(a)f Fo(c)n(onstructor)h Fp(to)f(yield)i(a)e Fo(value)p Fp(,)g(and)g(applying)i(a)0 2484 y Fo(typ)n(e)i(c)n(onstructor)e Fp(to)h(yield)h(a)f Fo(typ)n(e)p Fp(;)h(the)f(former)f(happ)q(ens)i(at)e(run-time)i(and)f(is)h(ho)o(w)e(w)o(e) h(compute)g(things)p 0 2525 780 2 v 52 2552 a Fl(5)69 2568 y Fk(T)m(uples)13 b(are)g(somewhat)g(lik)o(e)h Fe(r)n(e)n(c)n(or)n(ds)d Fk(in)i(other)g(languages,)h(except)f(that)g(the)g(elemen)o(ts)g(are)g(p)q (ositional,)i(rather)e(than)g(ha)o(ving)0 2614 y(names)h(\(lab)q(els\))g (asso)q(ciated)h(with)f(them.)p eop %%Page: 6 6 bop 0 -40 a Fp(T-6)906 b Fj(2)45 b(V)-5 b(ALUES,)16 b(TYPES,)e(AND)h(OTHER)h (GOODIES)0 105 y Fp(in)g(Hask)o(ell,)h(whereas)e(the)h(latter)f(happ)q(ens)i (at)e(compile-time)i(and)f(is)g(part)f(of)g(the)h(t)o(yp)q(e)g(system's)f (pro)q(cess)g(of)0 162 y(ensuring)h(t)o(yp)q(e)f(safet)o(y)l(.)0 298 y Fg(2.3)56 b(Recursiv)n(e)17 b(T)n(yp)r(es)0 402 y Fp(T)o(yp)q(es)e(can) h(also)f(b)q(e)h(recursiv)o(e,)f(as)g(in:)71 511 y Fi(data)23 b(Tree)g(a)310 b(=)24 b(Leaf)f(a)h(|)g(Branch)f(\(Tree)g(a\))h(\(Tree)f(a\))0 620 y Fp(Here)11 b(w)o(e)g(ha)o(v)o(e)f(de\014ned)i(a)f(p)q(olymorphic)h (binary)g(tree)e(t)o(yp)q(e)h(whose)g(elemen)o(ts)g(are)g(either)h(leaf)f(no) q(des)g(con)o(taining)0 677 y(a)k(v)m(alue)h(of)f(t)o(yp)q(e)g Fi(a)p Fp(,)g(or)g(in)o(ternal)h(no)q(des)g(\(\\branc)o(hes"\))e(con)o (taining)i(\(recursiv)o(ely\))g(t)o(w)o(o)e(sub-trees.)71 751 y(When)e(reading)g(data)f(declarations)h(suc)o(h)g(as)f(this,)i(remem)o(b)q (er)f(that)f Fi(Tree)g Fp(is)h(a)f(t)o(yp)q(e)h(constructor,)f(whereas)0 808 y Fi(Branch)k Fp(and)i Fi(Leaf)f Fp(are)g(data)f(constructors.)22 b(Aside)c(from)d(establishing)j(a)e(connection)i(b)q(et)o(w)o(een)e(these)h (con-)0 864 y(structors,)d(the)h(ab)q(o)o(v)o(e)g(declaration)h(is)g(essen)o (tially)g(de\014ning)h(the)e(follo)o(wing)h(t)o(yp)q(es)f(for)g Fi(Branch)f Fp(and)i Fi(Leaf)o Fp(:)71 973 y Fi(Branch)428 b(::)24 b(Tree)f(a)h(->)g(Tree)f(a)h(->)f(Tree)g(a)71 1030 y(Leaf)476 b(::)24 b(a)g(->)f(Tree)h(a)71 1182 y Fp(With)18 b(this)h(example)g(w)o(e)f(ha)o(v)o(e)f(de\014ned)j(a)e(t)o(yp)q(e)g (su\016cien)o(tly)i(ric)o(h)f(to)e(allo)o(w)i(de\014ning)g(some)f(in)o (teresting)0 1238 y(\(recursiv)o(e\))f(functions)h(that)e(use)h(it.)26 b(F)l(or)16 b(example,)i(supp)q(ose)g(w)o(e)e(wish)i(to)e(de\014ne)i(a)f (function)h Fi(fringe)e Fp(that)0 1295 y(returns)c(a)h(list)g(of)f(all)h(the) g(elemen)o(ts)g(in)g(the)g(lea)o(v)o(es)g(of)f(a)g(tree)g(from)g(left)h(to)f (righ)o(t.)18 b(It's)13 b(usually)g(helpful)i(to)d(write)0 1351 y(do)o(wn)k(the)g(t)o(yp)q(e)g(of)g(new)g(functions)h(\014rst;)f(in)h (this)f(case)g(w)o(e)g(see)h(that)e(the)h(t)o(yp)q(e)g(should)h(b)q(e)g Fi(Tree)23 b(a)h(->)g([a])o Fp(.)0 1408 y(That)16 b(is,)h Fi(fringe)e Fp(is)i(a)f(p)q(olymorphic)i(function)f(that,)f(for)g(an)o(y)g(t)o(yp)q(e)g Fi(a)p Fp(,)h(maps)f(trees)g(of)g Fi(a)g Fp(in)o(to)g(lists)i(of)e Fi(a)o Fp(.)24 b(A)0 1464 y(suitable)16 b(de\014nition)h(follo)o(ws:)71 1564 y Fi(fringe)23 b(::)g(Tree)h(a)f(->)h([a])71 1621 y(fringe)f(\(Leaf)g (x\))286 b(=)24 b([x])71 1677 y(fringe)f(\(Branch)g(left)g(right\))g(=)h (fringe)f(left)g(++)h(fringe)f(right)0 1789 y Fp(Where)13 b Fi(++)f Fp(is)i(the)f(in\014x)h(op)q(erator)e(that)g(concatenates)g(t)o(w)o (o)g(lists)h(\(its)g(full)h(de\014nition)h(will)g(b)q(e)e(giv)o(en)g(in)h (Section)0 1845 y(3.2\).)20 b(As)15 b(with)h(the)g Fi(length)e Fp(example)j(giv)o(en)f(earlier,)g Fi(fringe)f Fp(is)h(de\014ned)h(using)f (pattern)f(matc)o(hing,)g(except)0 1902 y(that)j(here)g(w)o(e)g(see)h (patterns)f(in)o(v)o(olving)i(user-de\014ned)g(constructors:)25 b Fi(Leaf)18 b Fp(and)g Fi(Branch)o Fp(.)30 b([Note)17 b(that)h(the)0 1958 y(formal)d(parameters)f(are)h(easily)h(iden)o(ti\014ed)i(as)c(the)i (ones)f(b)q(eginning)i(with)f(lo)o(w)o(er-case)f(letters.])0 2095 y Fg(2.4)56 b(T)n(yp)r(e)18 b(Synon)n(yms)0 2199 y Fp(F)l(or)g(con)o(v)o (enience,)i(Hask)o(ell)g(pro)o(vides)e(a)h(w)o(a)o(y)e(to)h(de\014ne)h Fo(typ)n(e)h(synonyms)p Fp(;)e(i.e.)g(names)h(for)f(commonly)g(used)0 2255 y(t)o(yp)q(es.)i(T)o(yp)q(e)15 b(synon)o(yms)g(are)g(created)g(using)h (a)f Fi(type)g Fp(declaration)h(\()p Fn(x)p Fp(4.2.2\).)h(Here)f(are)f(sev)o (eral)g(examples:)71 2367 y Fi(type)23 b(String)309 b(=)24 b([Char])71 2423 y(type)f(Person)309 b(=)24 b(\(Name,Address\))71 2480 y(type)f(Name)357 b(=)24 b(String)71 2536 y(data)f(Address)285 b(=)24 b(None)f(|)h(Addr)f(String)p eop %%Page: 7 7 bop 0 -40 a Fj(2.5)45 b(Built-in)17 b(T)o(yp)q(es)e(Are)h(Not)e(Sp)q(ecial) 1157 b Fp(T-7)71 105 y(T)o(yp)q(e)18 b(synon)o(yms)g(do)g(not)g(de\014ne)i (new)f(t)o(yp)q(es,)f(but)h(simply)h(giv)o(e)e(new)h(names)f(for)g(existing)h (t)o(yp)q(es.)30 b(F)l(or)0 162 y(example,)15 b(the)g(t)o(yp)q(e)f Fi(Person)23 b(->)h(Name)14 b Fp(is)h(precisely)h(equiv)m(alen)o(t)h(to)d Fi(\(String,Address\))21 b(->)j(String)o Fp(.)c(The)0 218 y(new)f(names)f (are)g(often)g(shorter)g(than)g(the)h(t)o(yp)q(es)f(they)g(are)h(synon)o (ymous)f(with,)h(but)f(this)h(is)g(not)f(the)g(only)0 274 y(purp)q(ose)13 b(of)e(t)o(yp)q(e)h(synon)o(yms:)18 b(they)12 b(can)g(also)g(impro)o(v)o(e)g (readabilit)o(y)h(of)e(programs)g(b)o(y)h(b)q(eing)h(more)e(mnemonic;)0 331 y(indeed,)17 b(the)e(ab)q(o)o(v)o(e)g(examples)h(highligh)o(t)g(this.)21 b(W)l(e)15 b(can)g(ev)o(en)h(giv)o(e)f(new)h(names)f(to)f(p)q(olymorphic)j(t) o(yp)q(es:)71 440 y Fi(type)23 b(AssocList)g(a)g(b)334 b(=)24 b([\(a,b\)])0 549 y Fp(This)16 b(is)f(the)h(t)o(yp)q(e)f(of)g(\\asso)q (ciation)g(lists")h(whic)o(h)g(asso)q(ciate)f(v)m(alues)h(of)f(t)o(yp)q(e)g Fi(a)g Fp(with)h(those)f(of)g(t)o(yp)q(e)g Fi(b)p Fp(.)0 723 y Fg(2.5)56 b(Built-in)17 b(T)n(yp)r(es)h(Are)g(Not)g(Sp)r(ecial)0 845 y Fp(Earlier)12 b(w)o(e)e(in)o(tro)q(duced)j(sev)o(eral)e(\\built-in")i (t)o(yp)q(es)d(suc)o(h)i(as)e(lists,)j(tuples,)f(in)o(tegers,)f(and)h(c)o (haracters.)17 b(W)l(e)11 b(ha)o(v)o(e)0 902 y(also)k(sho)o(wn)g(ho)o(w)g (new)g(user-de\014ned)i(t)o(yp)q(es)f(can)f(b)q(e)h(de\014ned.)21 b(Aside)c(from)d(sp)q(ecial)j(syn)o(tax,)d(are)h(the)h(built-in)0 958 y(t)o(yp)q(es)e(in)h(an)o(y)f(w)o(a)o(y)f(more)h(sp)q(ecial)i(than)e(the) g(user-de\014ned)i(ones?)k(The)14 b(answ)o(er)g(is)h Fo(no)p Fp(.)k(The)14 b(sp)q(ecial)i(syn)o(tax)d(is)0 1015 y(for)i(con)o(v)o(enience) h(and)g(for)e(consistency)i(with)g(historical)g(con)o(v)o(en)o(tion,)f(but)h (has)f(no)g(seman)o(tic)g(consequence.)71 1104 y(W)l(e)d(can)h(emphasize)h (this)f(p)q(oin)o(t)g(b)o(y)f(considering)i(what)e(the)h(t)o(yp)q(e)f (declarations)h(w)o(ould)g(lo)q(ok)g(lik)o(e)h(for)e(these)0 1161 y(built-in)19 b(t)o(yp)q(es)e(if)g(in)h(fact)e(w)o(e)g(w)o(ere)h(allo)o (w)o(ed)g(to)f(use)h(the)g(sp)q(ecial)h(syn)o(tax)e(in)i(de\014ning)g(them.) 24 b(F)l(or)16 b(example,)0 1217 y(the)f Fi(Char)g Fp(t)o(yp)q(e)g(migh)o(t)g (b)q(e)h(written)f(as:)71 1326 y Fi(data)23 b(Char)166 b(=)24 b('a')g(|)f('b')h(|)f('c')h(|)g(...)214 b(--)24 b(This)f(is)h(not)f(valid)452 1382 y(|)h('A')g(|)f('B')h(|)f('C')h(|)g(...)214 b(--)24 b(Haskell)f(code!) 452 1439 y(|)h('1')g(|)f('2')h(|)f('3')h(|)g(...)452 1495 y(...)0 1604 y Fp(These)14 b(constructor)f(names)h(are)g(not)f(syn)o(tactically)i(v)m (alid;)h(to)d(\014x)h(them)g(w)o(e)g(w)o(ould)g(ha)o(v)o(e)f(to)h(write)g (something)0 1661 y(lik)o(e:)71 1761 y Fi(data)23 b(Char)166 b(=)24 b(Ca)g(|)f(Cb)h(|)g(Cc)f(|)h(...)452 1818 y(|)g(CA)g(|)f(CB)h(|)g(CC)f (|)h(...)452 1874 y(|)g(C1)g(|)f(C2)h(|)g(C3)f(|)h(...)452 1930 y(...)0 2040 y Fp(Ev)o(en)18 b(though)g(these)g(constructors)f(are)g (more)h(concise,)h(they)f(are)g(quite)g(uncon)o(v)o(en)o(tional)h(for)e (represen)o(ting)0 2096 y(c)o(haracters.)71 2185 y(In)k(an)o(y)g(case,)h (writing)g(\\pseudo-Hask)o(ell")g(co)q(de)g(in)g(this)g(w)o(a)o(y)e(helps)i (us)f(to)g(see)g(through)g(the)g(sp)q(ecial)0 2242 y(syn)o(tax.)h(W)l(e)16 b(see)g(no)o(w)g(that)f Fi(Char)h Fp(is)g(just)g(an)g(en)o(umerated)g(t)o(yp) q(e)g(consisting)h(of)f(a)g(large)g(n)o(um)o(b)q(er)g(of)g(n)o(ullary)0 2298 y(constructors.)j(Thinking)d(of)e Fi(Char)g Fp(in)i(this)f(w)o(a)o(y)e (mak)o(es)h(it)h(clear)g(wh)o(y)l(,)g(for)f(example,)h(w)o(e)f(can)h (pattern-matc)o(h)0 2355 y(against)j(c)o(haracters)g(in)i(function)f (de\014nitions;)j(i.e.,)e(w)o(e)e(w)o(ould)h(exp)q(ect)h(to)e(b)q(e)h(able)g (to)g(do)f(so)h(for)f(an)o(y)g(of)g(a)0 2411 y(t)o(yp)q(e's)d(constructors.) 71 2501 y([This)20 b(example)i(also)e(demonstrates)g(the)h(use)g(of)f Fo(c)n(omments)f Fp(in)j(Hask)o(ell;)i(the)c(c)o(haracters)g Fi(--)g Fp(and)h(all)0 2557 y(subsequen)o(t)f(c)o(haracters)e(to)g(the)h(end) g(of)g(the)g(line)h(are)f(ignored.)32 b(Hask)o(ell)19 b(also)g(p)q(ermits)h Fo(neste)n(d)e Fp(commen)o(ts)0 2614 y(whic)o(h)e(ha)o(v)o(e)f(the)g(form)g Fi({-)o Fh(:)8 b(:)g(:)n Fi(-})15 b Fp(and)h(can)f(app)q(ear)g(an)o(ywhere)g (\()p Fn(x)p Fp(2.2\).])p eop %%Page: 8 8 bop 0 -40 a Fp(T-8)906 b Fj(2)45 b(V)-5 b(ALUES,)16 b(TYPES,)e(AND)h(OTHER)h (GOODIES)71 105 y Fp(Similarly)l(,)h(w)o(e)e(could)h(de\014ne)g Fi(Int)f Fp(and)g Fi(Integer)f Fp(b)o(y:)71 215 y Fi(data)23 b(Int)119 b(=)24 b(-65532)f(|)g(...)h(|)f(-1)h(|)g(0)g(|)f(1)h(|)g(...)f(|)h (65532)47 b(--)24 b(more)f(pseudo-code)71 272 y(data)g(Integer)g(=)167 b(...)23 b(-2)h(|)f(-1)h(|)g(0)g(|)f(1)h(|)g(2)f(...)0 381 y Fp(where)15 b Fi(-65532)g Fp(and)g Fi(65532)p Fp(,)f(sa)o(y)l(,)h(are)g (the)g(maxim)o(um)g(and)h(minim)o(um)g(\014xed)g(precision)h(in)o(tegers)e (for)g(a)f(giv)o(en)0 437 y(implemen)o(tation.)22 b Fi(Int)15 b Fp(is)h(a)f(m)o(uc)o(h)h(larger)f(en)o(umeration)h(than)f Fi(Char)p Fp(,)g(but)h(it's)f(still)i(\014nite!)22 b(In)16 b(con)o(trast,)e(the)0 494 y(pseudo-co)q(de)h(for)f Fi(Integer)f Fp(\(the)g(t)o(yp)q(e)h(of)g(arbitrary)f(precision)j(in)o(tegers\))e(is)g(in) o(tended)h(to)f(con)o(v)o(ey)g(an)f Fo(in\014nite)0 550 y Fp(en)o(umeration.) 71 671 y(T)l(uples)j(are)f(also)g(easy)g(to)g(de\014ne)h(pla)o(ying)g(this)g (game:)71 780 y Fi(data)23 b(\(a,b\))333 b(=)24 b(\(a,b\))596 b(--)24 b(more)f(pseudo-code)71 836 y(data)g(\(a,b,c\))285 b(=)24 b(\(a,b,c\))71 893 y(data)f(\(a,b,c,d\))237 b(=)24 b(\(a,b,c,d\))94 949 y(.)597 b(.)94 1006 y(.)g(.)94 1062 y(.)g(.)0 1171 y Fp(Eac)o(h)12 b(declaration)h(ab)q(o)o(v)o(e)e(de\014nes)j(a)d(tuple)i(t)o(yp)q(e)g(of)e(a) h(particular)h(length,)g(with)f Fi(\(...\))g Fp(pla)o(ying)h(a)e(role)i(in)g (b)q(oth)0 1228 y(the)g(expresssion)g(syn)o(tax)f(\(as)f(data)h (constructor\))g(and)g(t)o(yp)q(e-expression)i(syn)o(tax)e(\(as)f(t)o(yp)q(e) i(constructor\).)18 b(The)0 1284 y(v)o(ertical)11 b(dots)f(after)g(the)g (last)h(declaration)g(are)f(in)o(tended)i(to)e(con)o(v)o(ey)g(an)h (in\014nite)h(n)o(um)o(b)q(er)f(of)f(suc)o(h)h(declarations,)0 1341 y(re\015ecting)16 b(the)f(fact)g(that)g(tuples)h(of)e(all)j(lengths)e (are)g(allo)o(w)o(ed)h(in)g(Hask)o(ell.)71 1461 y(Lists)f(are)g(also)g (easily)i(handled,)f(and)f(more)g(in)o(terestingly)l(,)h(they)g(are)f (recursiv)o(e:)94 1570 y Fi(data)24 b([a])357 b(=)24 b([])g(|)f(a)h(:)g([a]) 429 b(--)24 b(more)f(pseudo-code)0 1679 y Fp(W)l(e)13 b(can)g(no)o(w)g(see)g (clearly)i(what)d(w)o(e)h(describ)q(ed)i(ab)q(out)e(lists)h(earlier:)20 b Fi([])12 b Fp(is)i(the)f(empt)o(y)g(list,)h(and)f Fi(:)g Fp(is)h(the)f(in\014x)0 1736 y(list)20 b(constructor;)f(th)o(us)g Fi([1,2,3])f Fp(m)o(ust)g(b)q(e)i(equiv)m(alen)o(t)g(to)e(the)h(list)h Fi(1:2:3:[])o Fp(.)31 b(\()p Fi(:)18 b Fp(is)i(righ)o(t)e(asso)q(ciativ)o (e.\))0 1792 y(The)d(t)o(yp)q(e)h(of)e Fi([])h Fp(is)h Fi([a])p Fp(,)e(and)i(the)f(t)o(yp)q(e)g(of)g Fi(:)g Fp(is)h Fi(a->[a]->[a])n Fp(.)71 1913 y([The)i(w)o(a)o(y)f Fi(:)h Fp(is)h(de\014ned)h(here)f(is)g (actually)g(legal)g(syn)o(tax|in\014x)h(constructors)d(are)h(p)q(ermitted)h (in)h Fi(data)0 1969 y Fp(declarations,)13 b(and)f(are)g(distinguished)j (from)c(in\014x)j(op)q(erators)d(\(for)g(pattern-matc)o(hing)h(purp)q(oses\)) g(b)o(y)g(the)h(fact)0 2026 y(that)h(they)i(m)o(ust)e(b)q(egin)j(with)e(a)g Fi(:)g Fp(\(a)g(prop)q(ert)o(y)g(trivially)i(satis\014ed)e(b)o(y)g Fi(:)p Fp(\).])71 2146 y(A)o(t)i(this)i(p)q(oin)o(t)f(the)g(reader)g(should)h (note)f(carefully)h(the)f(di\013erences)i(b)q(et)o(w)o(een)e(tuples)h(and)f (lists,)h(whic)o(h)0 2203 y(the)g(ab)q(o)o(v)o(e)f(de\014nitions)i(mak)o(e)e (abundan)o(tly)h(clear.)31 b(In)19 b(particular,)h(note)e(the)h(recursiv)o(e) g(nature)f(of)h(the)f(list)0 2259 y(t)o(yp)q(e)f(whose)g(elemen)o(ts)h(are)e (homogeneous)h(and)g(of)g(arbitrary)f(length,)i(and)f(the)g(non-recursiv)o(e) h(nature)f(of)f(a)0 2316 y(\(particular\))g(tuple)h(t)o(yp)q(e)f(whose)g (elemen)o(ts)h(are)e(heterogenous)h(and)g(of)g(\014xed)g(length.)23 b(The)17 b(t)o(yping)f(rules)h(for)0 2372 y(tuples)f(and)f(lists)h(should)h (no)o(w)d(also)h(b)q(e)h(clear:)71 2493 y(F)l(or)e Fi(\()p Fh(e)197 2500 y Fm(1)216 2493 y Fi(,)p Fh(e)261 2500 y Fm(2)281 2493 y Fi(,)8 b Fh(:)g(:)g(:)d Fi(,)p Fh(e)418 2500 y Fd(n)442 2493 y Fi(\))p Fh(;)22 b(n)13 b Fn(\025)g Fp(2,)h(if)h Fh(t)696 2500 y Fd(i)725 2493 y Fp(is)h(the)e(t)o(yp)q(e)h(of)g Fh(e)1023 2500 y Fd(i)1037 2493 y Fp(,)f(then)i(the)e(t)o(yp)q(e)h(of)g(the)g(tuple)g (is)h Fi(\()p Fh(t)1678 2500 y Fm(1)1698 2493 y Fi(,)p Fh(t)1738 2500 y Fm(2)1758 2493 y Fi(,)7 b Fh(:)h(:)g(:)e Fi(,)p Fh(t)1890 2500 y Fd(n)1914 2493 y Fi(\))o Fp(.)71 2614 y(F)l(or)14 b Fi([)p Fh(e)197 2621 y Fm(1)217 2614 y Fi(,)p Fh(e)262 2621 y Fm(2)282 2614 y Fi(,)7 b Fh(:)h(:)g(:)e Fi(,)p Fh(e)419 2621 y Fd(n)442 2614 y Fi(])p Fh(;)22 b(n)13 b Fn(\025)g Fp(0,)i(eac)o(h)g Fh(e)763 2621 y Fd(i)792 2614 y Fp(m)o(ust)g(ha)o(v)o(e)g(the)g(same)g(t)o (yp)q(e)g Fh(t)p Fp(,)h(and)f(the)g(t)o(yp)q(e)g(of)g(the)h(list)g(is)f Fi([)p Fh(t)p Fi(])p Fp(.)p eop %%Page: 9 9 bop 0 -40 a Fj(2.5)45 b(Built-in)17 b(T)o(yp)q(es)e(Are)h(Not)e(Sp)q(ecial) 1157 b Fp(T-9)0 105 y Fc(2.5.1)52 b(List)18 b(Comprehensions)e(and)i (Arithmetic)g(Sequences)0 211 y Fp(As)13 b(with)g(Lisp)h(dialects,)h(lists)e (are)g(p)q(erv)m(asiv)o(e)h(in)g(Hask)o(ell,)g(and)f(as)f(with)i(other)e (functional)i(languages,)f(there)g(is)0 268 y(y)o(et)e(more)g(syn)o(tactic)h (sugar)f(to)f(aid)j(in)f(their)g(creation.)19 b(Aside)12 b(from)f(the)h (constructors)e(for)h(lists)i(just)e(discussed,)0 324 y(Hask)o(ell)16 b(pro)o(vides)g(an)f(expression)h(kno)o(wn)f(as)g(a)g Fo(list)g(c)n(ompr)n (ehension)f Fp(that)h(is)g(b)q(est)h(explained)h(b)o(y)e(example:)71 433 y Fi([)23 b(f)h(x)g(|)f(x)h(<-)g(xs)f(])0 542 y Fp(This)17 b(expression)f(can)h(in)o(tuitiv)o(ely)h(b)q(e)e(read)g(as)g(\\the)g(list)g (of)g(all)h Fi(f)24 b(x)15 b Fp(suc)o(h)i(that)e Fi(x)h Fp(is)g(dra)o(wn)g (from)f Fi(xs)p Fp(.")22 b(The)0 599 y(similarit)o(y)d(to)f(set)g(notation)f (is)i(not)e(a)h(coincidence.)31 b(The)19 b(phrase)f Fi(x<-xs)f Fp(is)i(called)g(a)f Fo(gener)n(ator)p Fp(,)g(of)g(whic)o(h)0 655 y(more)d(than)g(one)g(is)h(allo)o(w)o(ed,)f(as)g(in:)71 764 y Fi([)23 b(\(x,y\))g(|)h(x<-xs,)f(y<-ys)g(])0 873 y Fp(This)17 b(list)f(comprehension)i(forms)d(the)h(cartesian)g(pro)q(duct)g(of)g(the)g(t) o(w)o(o)e(lists)j Fi(xs)f Fp(and)g Fi(ys)o Fp(.)22 b(The)17 b(elemen)o(ts)f(are)0 930 y(selected)f(as)f(if)h(the)f(generators)g(w)o(ere)g (\\nested")g(from)f(left)i(to)e(righ)o(t)h(\(with)h(the)f(righ)o(tmost)f (generator)g(v)m(arying)0 986 y(fastest\);)g(th)o(us,)i(if)h Fi(xs)f Fp(is)g Fi([1,2])g Fp(and)g Fi(ys)g Fp(is)h Fi([3,4])o Fp(,)f(the)g(result)h(is)g Fi([\(1,3\),\(1,4\),\(2,3\),\(2,4)o(\)])m Fp(.)71 1063 y(Besides)h(generators,)e(b)q(o)q(olean)i(expressions)g(called)g Fo(guar)n(ds)g Fp(are)e(p)q(ermitted.)24 b(Guards)15 b(place)i(constrain)o (ts)0 1119 y(on)d(the)g(elemen)o(ts)h(generated.)k(F)l(or)13 b(example,)i(here)f(is)h(a)f(concise)h(de\014nition)h(of)d(ev)o(eryb)q(o)q (dy's)h(fa)o(v)o(orite)f(sorting)0 1176 y(algorithm:)71 1285 y Fi(quicksort)46 b([])262 b(=)48 b([])71 1341 y(quicksort)22 b(\(x:xs\))190 b(=)48 b(quicksort)23 b([y)g(|)h(y)g(<-)f(xs,)h(y=x])71 1609 y Fp(T)l(o)16 b(further)h(supp)q(ort)g(the)g(use)g(of)g(lists,)h(Hask)o (ell)f(has)g(sp)q(ecial)i(syn)o(tax)d(for)h Fo(arithmetic)h(se)n(quenc)n(es)p Fp(,)d(whic)o(h)0 1665 y(are)g(b)q(est)g(explained)j(b)o(y)d(a)g(series)g(of) g(examples:)360 1750 y Fi([1..10])133 b Fn(\))88 b Fi([1,2,3,4,5,6,7,8,9,10]) 360 1806 y([1,3..10])d Fn(\))j Fi([1,3,5,7,9])360 1862 y([1,3..])133 b Fn(\))88 b Fi([1,3,5,7,9,)22 b(...)76 b Fp(\(in\014nite)16 b(sequence\))0 1947 y(More)f(will)h(b)q(e)g(said)g(ab)q(out)f(arithmetic)h (sequences)g(in)g(Section)g(5.2,)e(and)i(\\in\014nite)g(lists")g(in)g (Section)g(3.4.)0 2085 y Fc(2.5.2)52 b(Strings)0 2192 y Fp(As)15 b(another)f(example)h(of)f(syn)o(tactic)h(sugar)f(for)g(built-in)j(t)o(yp)q (es,)d(w)o(e)h(note)f(that)g(the)g(literal)i(string)f Fi("hello")e Fp(is)0 2248 y(actually)h(shorthand)f(for)f(the)h(list)h(of)f(c)o(haracters)f Fi(['h','e','l','l','o'])m Fp(.)19 b(Indeed,)c(the)e(t)o(yp)q(e)g(of)g Fi("hello")0 2305 y Fp(is)j Fi(String)o Fp(,)f(where)g Fi(String)f Fp(is)i(a)f(prede\014ned)i(t)o(yp)q(e)e(synon)o(ym)g(\(that)f(w)o(e)h(ga)o(v) o(e)f(as)h(an)g(earlier)h(example\):)71 2416 y Fi(type)23 b(String)309 b(=)24 b([Char])0 2525 y Fp(This)16 b(means)f(w)o(e)g(can)g(use)h (prede\014ned)h(p)q(olymorphic)f(list)g(functions)g(to)f(op)q(erate)g(on)g (strings.)20 b(F)l(or)14 b(example:)497 2614 y Fi("hello")23 b(++)h(")f(world")73 b Fn(\))h Fi("hello)23 b(world")p eop %%Page: 10 10 bop 0 -40 a Fp(T-10)1513 b Fj(3)45 b(FUNCTIONS)0 105 y Fq(3)69 b(F)-6 b(unctions)0 266 y Fp(Since)15 b(Hask)o(ell)g(is)f(a)f(functional)i (language,)f(one)f(w)o(ould)h(exp)q(ect)h(functions)f(to)f(pla)o(y)h(a)f(ma)s (jor)g(role,)g(and)h(indeed)0 323 y(they)h(do.)20 b(In)c(this)g(section,)f(w) o(e)g(lo)q(ok)g(at)g(sev)o(eral)g(asp)q(ects)h(of)e(functions)i(in)g(Hask)o (ell.)71 428 y(First,)e(consider)i(this)g(de\014nition)h(of)e(a)g(function)h (whic)o(h)g(adds)f(its)g(t)o(w)o(o)f(argumen)o(ts:)71 537 y Fi(add)500 b(::)24 b(Int)f(->)h(Int)f(->)h(Int)71 593 y(add)f(x)h(y)405 b(=)24 b(x)g(+)f(y)0 709 y Fp(This)18 b(is)g(an)f(example)i(of)e(a)g Fo(currie)n(d)h Fp(function.)826 692 y Fm(6)873 709 y Fp(An)g(application)h (of)e Fi(add)g Fp(has)g(the)h(form)f Fi(add)23 b Fh(e)1720 716 y Fm(1)1757 709 y Fh(e)1778 716 y Fm(2)1798 709 y Fp(,)18 b(and)f(is)0 765 y(equiv)m(alen)o(t)c(to)d Fi(\(add)24 b Fh(e)404 772 y Fm(1)423 765 y Fi(\))g Fh(e)492 772 y Fm(2)512 765 y Fp(,)12 b(since)g(function)g(application)h(asso)q(ciates)e(to)f(the)h Fo(left)p Fp(.)18 b(In)12 b(other)f(w)o(ords,)g(applying)0 822 y Fi(add)k Fp(to)g(one)h(argumen)o(t)f(yields)i(a)f(new)g(function)g (whic)o(h)h(is)f(then)g(applied)i(to)d(the)g(second)i(argumen)o(t.)j(This)c (is)0 878 y(consisten)o(t)g(with)h(the)f(t)o(yp)q(e)g(of)f Fi(add)p Fp(,)h Fi(Int->Int->Int)n Fp(,)g(whic)o(h)h(is)f(equiv)m(alen)o(t)i (to)d Fi(Int->\(Int->Int\))n Fp(;)h(i.e.)g Fi(->)0 934 y Fp(asso)q(ciates)f (to)f(the)h Fo(right)p Fp(.)21 b(Indeed,)16 b(using)g Fi(add)o Fp(,)f(w)o(e)g(can)g(de\014ne)h Fi(succ)e Fp(in)i(a)f(di\013eren)o(t)g(w)o(a) o(y)f(from)h(what)f(w)o(e)h(did)0 991 y(earlier:)71 1091 y Fi(succ)476 b(=)24 b(add)f(1)0 1200 y Fp(This)16 b(is)h(an)f(example)g(of)g (the)g Fo(p)n(artial)h(applic)n(ation)f Fp(of)f(a)h(curried)h(function,)f (and)g(is)h(one)f(w)o(a)o(y)e(that)i(a)f(function)0 1257 y(can)20 b(b)q(e)h(returned)g(as)f(a)f(v)m(alue.)36 b(Let's)20 b(consider)i(a)d(case)i (in)g(whic)o(h)g(it's)f(useful)h(to)e(pass)h(a)g(function)h(as)f(an)0 1313 y(argumen)o(t.)f(The)d(w)o(ell-kno)o(wn)g Fi(map)e Fp(function)i(is)g(a) f(p)q(erfect)h(example:)71 1423 y Fi(map)500 b(::)24 b(\(a->b\))f(->)h([a])f (->)h([b])71 1480 y(map)f(f)48 b([])357 b(=)24 b([])71 1536 y(map)f(f)h(\(x:xs\))285 b(=)24 b(f)g(x)f(:)h(map)g(f)f(xs)0 1648 y Fp([F)l(unction)16 b(application)h(has)f(higher)g(precedence)i(than)d (an)o(y)h(in\014x)g(op)q(erator,)f(and)h(th)o(us)f(the)h(righ)o(t-hand)g (side)0 1704 y(of)h(the)h(second)g(equation)f(parses)h(as)f Fi(\(f)23 b(x\))h(:)g(\(map)f(f)h(xs\))o Fp(.])52 b Fi(map)17 b Fp(is)h(a)f(p)q(olymorphic)i(function,)f(and)g(its)0 1761 y(t)o(yp)q(e)j(indicates)h(clearly)g(that)e(its)g(\014rst)h(argumen)o(t)f(is) h(a)f(function;)k(note)c(also)h(that)f(the)h(t)o(w)o(o)e Fi(a)p Fp('s)h(m)o(ust)g(b)q(e)0 1817 y(instan)o(tiated)e(with)h(the)f(same)g(t)o (yp)q(e)g(\(lik)o(ewise)i(for)d(the)i Fi(b)p Fp('s\).)27 b(As)19 b(an)f(example)h(of)e(the)i(use)f(of)g Fi(map)o Fp(,)h(w)o(e)f(can)0 1874 y(incremen)o(t)e(the)f(elemen)o(ts)h(in)g(a)f(list:)569 2011 y Fi(map)23 b(\(add)h(1\))f([1,2,3])72 b Fn(\))i Fi([2,3,4])71 2197 y Fp(These)18 b(examples)h(demonstrate)e(the)h(\014rst-class)g(nature)g (of)g(functions,)h(whic)o(h)g(when)f(used)h(in)g(this)f(w)o(a)o(y)0 2254 y(are)d(usually)h(called)h Fo(higher-or)n(der)f Fp(functions.)p 0 2341 780 2 v 52 2368 a Fl(6)69 2383 y Fk(The)i(name)h Fe(curry)e Fk(deriv)o(es)i(from)f(the)h(p)q(erson)g(who)f(p)q(opularized)j(the)e(idea:) 28 b(Hask)o(ell)20 b(Curry)m(.)32 b(T)m(o)18 b(get)g(the)g(e\013ect)h(of)e (an)0 2429 y Fe(uncurrie)n(d)11 b Fk(function,)j(w)o(e)e(could)j(use)e(a)g Fe(tuple)p Fk(,)e(as)i(in:)71 2518 y Ff(add)18 b(\(x,y\))292 b(=)20 b(x)f(+)g(y)0 2614 y Fk(But)13 b(then)h(w)o(e)e(see)h(that)h(this)f(v) o(ersion)i(of)e Ff(add)e Fk(is)j(really)h(just)e(a)g(function)h(of)f(one)g (argumen)o(t!)p eop %%Page: 11 11 bop 0 -40 a Fj(3.1)45 b(Lam)o(b)q(da)15 b(Abstractions)1324 b Fp(T-11)0 105 y Fg(3.1)56 b(Lam)n(b)r(da)17 b(Abstractions)0 215 y Fp(Instead)c(of)f(using)i(equations)e(to)g(de\014ne)i(functions,)g(w)o (e)e(can)h(also)f(de\014ne)i(them)f(\\anon)o(ymously")f(via)h(a)f Fo(lamb)n(da)0 271 y(abstr)n(action)p Fp(.)19 b(F)l(or)c(example,)g(a)g (function)h(equiv)m(alen)o(t)g(to)f Fi(succ)f Fp(could)i(b)q(e)g(written)f (as)f Fi(\\x)24 b(->)g(x+1)o Fp(.)c(Similarly)l(,)0 328 y(the)15 b(function)h Fi(add)f Fp(is)h(equiv)m(alen)o(t)h(to)e Fi(\\x)23 b(->)h(\\y)f(->)h(x+y)p Fp(.)c(Nested)15 b(lam)o(b)q(da)h(abstractions)f(suc) o(h)g(as)g(this)h(ma)o(y)0 384 y(b)q(e)g(written)f(using)h(the)f(equiv)m (alen)o(t)i(shorthand)e(notation)g Fi(\\x)24 b(y)f(->)h(x+y)p Fp(.)19 b(In)d(fact,)e(the)i(equations:)71 494 y Fi(succ)23 b(x)429 b(=)24 b(x+1)71 551 y(add)47 b(x)24 b(y)381 b(=)24 b(x+y)0 660 y Fp(are)15 b(really)h(shorthand)f(for:)71 769 y Fi(succ)476 b(=)24 b(\\x)71 b(->)24 b(x+1)71 825 y(add)500 b(=)24 b(\\x)g(y)f(->)h(x+y)0 934 y Fp(W)l(e)15 b(will)i(ha)o(v)o(e)e(more)g (to)f(sa)o(y)h(ab)q(out)g(suc)o(h)g(equiv)m(alences)j(later.)71 1015 y(In)d(general,)h(giv)o(en)f(that)g Fi(x)g Fp(has)g(t)o(yp)q(e)g Fh(t)752 1022 y Fm(1)788 1015 y Fp(and)g Fi(exp)g Fp(has)g(t)o(yp)q(e)g Fh(t)1162 1022 y Fm(2)1182 1015 y Fp(,)g(then)g Fi(\\x->exp)g Fp(has)g(t)o(yp)q(e)g Fh(t)1695 1022 y Fm(1)1715 1015 y Fi(->)p Fh(t)1779 1022 y Fm(2)1799 1015 y Fp(.)0 1160 y Fg(3.2)56 b(In\014x)18 b(Op)r(erators)0 1270 y Fp(In\014x)c(op)q(erators)d(are)i(really)h(just)e (functions,)i(and)f(can)g(also)f(b)q(e)i(de\014ned)g(using)f(equations.)20 b(F)l(or)12 b(example,)i(here)0 1326 y(is)i(the)f(de\014nition)i(of)e(Hask)o (ell's)g(list)h(concatenation)g(op)q(erator:)71 1435 y Fi(\(++\))476 b(::)24 b([a])f(->)h([a])f(->)h([a])71 1491 y([])119 b(++)23 b(ys)286 b(=)48 b(ys)71 1548 y(\(x:xs\))23 b(++)g(ys)286 b(=)48 b(x)24 b(:)f(\(xs++ys\))0 1660 y Fp([Lexically)l(,)17 b(in\014x)f(op)q (erators)d(consist)i(en)o(tirely)h(of)f(\\sym)o(b)q(ols,")f(as)g(opp)q(osed)i (to)e(normal)g(iden)o(ti\014ers)j(whic)o(h)e(are)0 1716 y(alphan)o(umeric)20 b(\()p Fn(x)p Fp(2.3\).)30 b(Hask)o(ell)20 b(has)e(no)h(pre\014x)h(op)q (erators,)e(with)h(the)g(exception)h(of)f(min)o(us)g(\()p Fi(-)p Fp(\),)g(whic)o(h)g(is)0 1772 y(b)q(oth)c(in\014x)i(and)e(pre\014x.])71 1853 y(As)f(another)h(example,)g(an)f(imp)q(ortan)o(t)h(in\014x)g(op)q (erator)f(on)h(functions)g(is)g(that)f(for)g Fo(function)i(c)n(omp)n(osition) p Fp(:)71 1962 y Fi(\(.\))500 b(::)24 b(\(b->c\))f(->)h(\(a->b\))f(->)g (\(a->c\))71 2018 y(f)g(.)h(g)453 b(=)24 b(\\)g(x)f(->)h(f)g(\(g)f(x\))0 2239 y Fc(3.2.1)52 b(Sections)0 2349 y Fp(Since)16 b(in\014x)g(op)q(erators)e (are)h(really)h(just)f(functions,)g(it)g(mak)o(es)f(sense)i(to)e(b)q(e)i (able)f(to)g(partially)h(apply)f(them)g(as)0 2405 y(w)o(ell.)21 b(In)16 b(Hask)o(ell)g(the)f(partial)h(application)g(of)f(an)g(in\014x)i(op)q (erator)d(is)i(called)g(a)f Fo(se)n(ction)p Fp(.)k(F)l(or)c(example:)676 2500 y Fi(\(x+\))102 b Fn(\021)126 b Fi(\\y)24 b(->)f(x+y)676 2557 y(\(+y\))102 b Fn(\021)126 b Fi(\\x)24 b(->)f(x+y)688 2613 y(\(+\))114 b Fn(\021)102 b Fi(\\x)24 b(y)g(->)f(x+y)p eop %%Page: 12 12 bop 0 -40 a Fp(T-12)1513 b Fj(3)45 b(FUNCTIONS)0 105 y Fp([The)15 b(paren)o(theses)g(are)g(mandatory)l(.])71 199 y(The)20 b(last)f(form)g(of)g (section)i(giv)o(en)f(ab)q(o)o(v)o(e)f(essen)o(tially)i(co)q(erces)g(an)e (in\014x)i(op)q(erator)e(in)o(to)h(an)f(equiv)m(alen)o(t)0 255 y(functional)h(v)m(alue,)h(and)e(is)g(handy)g(when)h(passing)f(an)g (in\014x)h(op)q(erator)e(as)g(an)h(argumen)o(t)f(to)h(a)f(function,)i(as)0 312 y(in)i Fi(map)h(\(+\))g([1,2,3])d Fp(\(the)h(reader)f(should)i(v)o(erify) f(that)f(this)h(returns)f(a)h(list)g(of)g(functions!\).)36 b(It)21 b(is)g(also)0 368 y(necessary)15 b(when)g(giving)g(a)g(function)g(t)o (yp)q(e)g(signature,)f(as)h(in)g(the)g(examples)g(of)f Fi(\(++\))g Fp(and)h Fi(\(.\))f Fp(giv)o(en)h(earlier.)71 462 y(W)l(e)20 b(can)h(no)o(w)g(see)g(that)f Fi(add)g Fp(de\014ned)i(earlier)g(is)f(just)g Fi(\(+\))p Fp(,)g(and)g Fi(succ)f Fp(is)i(just)e Fi(\(+1\))p Fp(!)36 b(Indeed,)24 b(these)0 518 y(de\014nitions)17 b(w)o(ould)f(do)f(just) g(\014ne:)71 627 y Fi(succ)476 b(=)24 b(\(+1\))71 684 y(add)500 b(=)24 b(\(+\))71 855 y Fp(W)l(e)14 b(can)g(co)q(erce)h(an)f(in\014x)h(op)q (erator)e(in)o(to)h(a)g(functional)h(v)m(alue,)g(but)g(can)f(w)o(e)g(go)f (the)h(other)g(w)o(a)o(y?)19 b(Y)l(es|w)o(e)0 912 y(simply)g(enclose)g(an)f (iden)o(ti\014er)h(b)q(ound)g(to)e(a)h(functional)h(v)m(alue)g(in)g(bac)o (kquotes.)27 b(F)l(or)17 b(example,)i Fi(x)24 b(`add`)f(y)0 968 y Fp(is)17 b(the)g(same)g(as)f Fi(add)23 b(x)h(y)p Fp(.)480 952 y Fm(7)524 968 y Fp(Some)17 b(functions)h(read)e(b)q(etter)h(this)g(w)o (a)o(y)l(.)24 b(An)17 b(example)h(is)f(the)g(prede\014ned)h(list)0 1025 y(mem)o(b)q(ership)13 b(predicate)g Fi(elem)p Fp(;)f(the)g(expression)h Fi(x)24 b(`elem`)f(xs)12 b Fp(can)g(b)q(e)h(read)f(in)o(tuitiv)o(ely)i(as)d (\\)p Fi(x)h Fp(is)g(an)g(elemen)o(t)0 1081 y(of)j Fi(xs)o Fp(.")71 1175 y([There)c(are)g(some)g(sp)q(ecial)i(rules)f(regarding)g (sections)g(in)o(v)o(olving)g(the)g(pre\014x/in\014x)g(op)q(erator)f Fi(-)g Fp(\()p Fn(x)p Fp(3.4,)p Fn(x)o Fp(3.3\).])71 1269 y(A)o(t)16 b(this)i(p)q(oin)o(t,)g(the)f(reader)g(ma)o(y)g(b)q(e)h(confused)g(at)e(ha)o (ving)i(so)f(man)o(y)g(w)o(a)o(ys)f(to)g(de\014ne)j(a)e(function!)27 b(The)0 1325 y(decision)18 b(to)d(pro)o(vide)h(these)g(mec)o(hanisms)g (partly)g(re\015ects)g(historical)h(con)o(v)o(en)o(tions,)e(and)h(partly)g (re\015ects)g(the)0 1382 y(desire)g(for)f(consistency)h(\(for)e(example,)i (in)g(the)f(treatmen)o(t)f(of)h(in\014x)h(vs.)k(regular)15 b(functions\).)0 1568 y Fc(3.2.2)52 b(Fixit)o(y)17 b(Declarations)0 1697 y Fp(A)f Fo(\014xity)g(de)n(clar)n(ation)f Fp(can)h(b)q(e)h(giv)o(en)f (for)f(an)o(y)g(in\014x)i(op)q(erator)e(or)g(constructor)g(\(including)j (those)e(made)g(from)0 1754 y(ordinary)j(iden)o(ti\014ers,)j(suc)o(h)d(as)g Fi(`elem`)o Fp(\).)754 1737 y Fm(8)805 1754 y Fp(This)h(declaration)g(sp)q (eci\014es)g(a)f(precedence)i(lev)o(el)g(from)d(0)h(to)f(9)0 1810 y(\(with)e(9)g(b)q(eing)i(the)e(strongest;)f(normal)i(application)h(is)e (assumed)h(to)e(ha)o(v)o(e)h(a)g(precedence)i(lev)o(el)g(of)e(10\),)f(and)0 1867 y(left-,)g(righ)o(t-,)g(or)g(non-asso)q(ciativit)o(y)l(.)21 b(F)l(or)14 b(example,)i(the)f(\014xit)o(y)h(declarations)f(for)g Fi(++)g Fp(and)g Fi(.)g Fp(are:)71 1976 y Fi(infixr)23 b(5)g(++)71 2032 y(infixr)g(9)g(.)0 2141 y Fp(Both)18 b(of)g(these)g(sp)q(ecify)i(righ)o (t-asso)q(ciativit)o(y)l(,)f(the)g(\014rst)e(with)i(a)f(precedence)i(lev)o (el)g(of)d(5,)i(the)f(other)g(9.)29 b(Left)0 2198 y(asso)q(ciativit)o(y)15 b(is)h(sp)q(eci\014ed)g(via)g Fi(infixl)o Fp(,)e(and)h(non-asso)q(ciativit)o (y)h(b)o(y)f Fi(infix)o Fp(.)20 b(Also,)14 b(the)h(\014xit)o(y)g(of)g(more)f (than)0 2254 y(one)h(op)q(erator)f(ma)o(y)g(b)q(e)h(sp)q(eci\014ed)i(with)f (the)e(same)h(\014xit)o(y)g(declaration.)21 b(If)15 b(no)f(\014xit)o(y)h (declaration)h(is)f(giv)o(en)h(for)0 2310 y(a)c(particular)h(op)q(erator,)f (it)h(defaults)g(to)f Fi(infixl)23 b(9)p Fp(.)c(\(See)13 b Fn(x)p Fp(5.7)e(for)h(a)g(detailed)i(de\014nition)h(of)d(the)h(asso)q (ciativit)o(y)0 2367 y(rules.\))p 0 2434 780 2 v 52 2461 a Fl(7)69 2477 y Fk(Note)g(carefully)i(that)e Ff(add)f Fk(is)i(enclosed)h(in)e Fe(b)n(ackquotes)p Fk(,)c(not)14 b Fe(ap)n(ostr)n(ophes)9 b Fk(as)14 b(used)f(in)h(the)g(syn)o(tax)g(of)e(c)o(haracters;)i(i.e.)j Ff('f')12 b Fk(is)0 2522 y(a)g(c)o(haracter,)h(whereas)g Ff(`f`)e Fk(is)i(an)f(in\014x)i(op)q(erator.)k(F)m(ortunately)m(,)13 b(most)f(ASCI)q(I)g(terminals)i(distingui)q(sh)h(these)e(m)o(uc)o(h)g(b)q (etter)f(than)0 2568 y(the)h(t)o(yp)q(efon)o(t)h(used)f(in)h(this)g(man)o (uscript.)52 2598 y Fl(8)69 2614 y Fk(Fixit)o(y)f(declarations)i(m)o(ust)c (only)i(app)q(ear)g(at)e(the)h(v)o(ery)g(b)q(eginning)j(of)c(a)g(Hask)o(ell)j Fe(mo)n(dule)p Fk(,)c(as)h(will)i(b)q(e)f(describ)q(ed)i(in)e(Section)h(6.)p eop %%Page: 13 13 bop 0 -40 a Fj(3.3)45 b(F)l(unctions)15 b(are)g(Non-strict)1269 b Fp(T-13)0 105 y Fg(3.3)56 b(F)-5 b(unctions)19 b(are)f(Non-strict)0 215 y Fp(Supp)q(ose)e Fi(bot)f Fp(is)h(de\014ned)g(b)o(y:)71 324 y Fi(bot)500 b(=)24 b(bot)0 433 y Fp(In)c(other)e(w)o(ords,)h Fi(bot)g Fp(is)h(a)e(non-terminating)i(expression.)33 b(Abstractly)l(,)20 b(w)o(e)e(denote)i(the)f Fo(value)g Fp(of)g(a)g(non-)0 489 y(terminating)d(expression)h(as)f Fn(?)g Fp(\(read)g(\\b)q(ottom"\).)21 b(Expressions)16 b(that)g(result)g(in)h(some)f(kind)h(of)e(a)h(run-time)0 546 y(error,)e(suc)o(h)i(as)e Fi(1/0)p Fp(,)h(also)g(ha)o(v)o(e)g(this)g(v)m (alue.)71 626 y(A)f(function)i Fi(f)e Fp(is)h(said)g(to)f(b)q(e)i Fo(strict)e Fp(if,)h(when)g(applied)h(to)e(a)h(non)o(terminating)g (expression,)g(it)g(also)f(fails)i(to)0 682 y(terminate.)j(In)14 b(other)g(w)o(ords,)e Fi(f)i Fp(is)g(strict)f(i\013)h(the)f(v)m(alue)i(of)e Fi(f)24 b(bot)13 b Fp(is)h Fn(?)p Fp(.)20 b(F)l(or)13 b(most)f(programming)h (languages,)0 739 y Fo(al)r(l)k Fp(functions)h(are)e(strict.)25 b(But)17 b(this)h(is)f(not)g(so)g(in)g(Hask)o(ell.)27 b(As)17 b(a)f(simple)j(example,)f(consider)g Fi(const1)o Fp(,)f(the)0 795 y(constan)o(t)d(1)h(function,)h(de\014ned)g(b)o(y:)71 904 y Fi(const1)23 b(x)381 b(=)24 b(1)0 1013 y Fp(The)18 b(v)m(alue)h(of)f Fi(const1)23 b(bot)17 b Fp(in)i(Hask)o(ell)f(is)h Fi(1)p Fp(.)27 b(Op)q(erationally)20 b(sp)q(eaking,)f(since)g Fi(const1)e Fp(do)q(es)h(not)g(\\need")0 1070 y(the)d(v)m(alue)g(of)f(its)h(argumen)o(t,) f(it)g(nev)o(er)h(attempts)e(to)h(ev)m(aluate)i(it,)e(and)h(th)o(us)f(nev)o (er)h(gets)f(caugh)o(t)g(in)h(a)f(non)o(ter-)0 1126 y(minating)k (computation.)26 b(F)l(or)16 b(this)i(reason,)f(non-strict)h(functions)g(are) e(also)i(called)g(\\lazy)g(functions,")g(and)0 1183 y(are)d(said)h(to)e(ev)m (aluate)i(their)g(argumen)o(ts)e(\\lazily)l(,")i(or)f(\\b)o(y)g(need.")71 1263 y(Since)e(error)e(and)h(non)o(terminating)h(v)m(alues)g(are)e(seman)o (tically)j(the)e(same)f(in)i(Hask)o(ell,)g(the)f(ab)q(o)o(v)o(e)g(argumen)o (t)0 1319 y(also)j(holds)h(for)f(errors.)k(F)l(or)14 b(example,)i Fi(const1)23 b(\(1/0\))15 b Fp(also)g(ev)m(aluates)h(prop)q(erly)g(to)e Fi(1)p Fp(.)71 1400 y(Non-strict)h(functions)i(are)f(extremely)g(useful)h(in) g(a)e(v)m(ariet)o(y)h(of)g(con)o(texts.)21 b(The)16 b(main)g(adv)m(an)o(tage) f(is)i(that)0 1456 y(they)d(free)f(the)h(programmer)f(from)f(man)o(y)i (concerns)g(ab)q(out)f(ev)m(aluation)i(order.)k(Computationally)14 b(exp)q(ensiv)o(e)0 1513 y(v)m(alues)j(ma)o(y)f(b)q(e)h(passed)g(as)e (argumen)o(ts)h(to)g(functions)h(without)f(fear)g(of)g(them)g(b)q(eing)h (computed)g(if)g(they)f(are)0 1569 y(not)f(needed.)21 b(An)15 b(imp)q(ortan)o(t)g(example)h(of)f(this)h(is)f(a)g(p)q(ossibly)i Fo(in\014nite)d Fp(data)g(structure.)0 1714 y Fg(3.4)56 b(\\In\014nite")17 b(Data)i(Structures)0 1824 y Fp(One)13 b(adv)m(an)o(tage)f(of)g(the)g (non-strict)h(nature)f(of)g(Hask)o(ell)h(is)g(that)f(data)g(constructors)f (are)h(non-strict,)h(to)q(o.)18 b(This)0 1880 y(should)h(not)e(b)q(e)i (surprising,)g(since)g(constructors)e(are)g(really)i(just)e(a)h(sp)q(ecial)h (kind)g(of)e(function)i(\(the)e(distin-)0 1937 y(guishing)h(feature)e(b)q (eing)i(that)e(they)g(can)h(b)q(e)g(used)g(in)g(pattern)f(matc)o(hing\).)24 b(F)l(or)16 b(example,)h(the)g(constructor)0 1993 y(for)e(lists,)g Fi(\(:\))p Fp(,)g(is)g(non-strict.)71 2073 y(Non-strict)g(constructors)f(p)q (ermit)h(the)g(de\014nition)i(of)e(\(conceptually\))h Fo(in\014nite)d Fp(data)i(structures.)k(Here)c(is)0 2130 y(an)g(in\014nite)i(list)f(of)f (ones:)71 2230 y Fi(ones)476 b(=)24 b(1)g(:)f(ones)0 2339 y Fp(P)o(erhaps)15 b(more)g(in)o(teresting)h(is)f(the)h(function)g Fi(numsFrom)o Fp(:)71 2448 y Fi(numsFrom)22 b(n)334 b(=)24 b(n)g(:)f(numsFrom)g(\(n+1\))0 2557 y Fp(Th)o(us)10 b Fi(numsFrom)23 b(n)11 b Fp(is)g(the)f(in\014nite)j(list)e(of)f(successiv)o(e)i(in)o(tegers)e (b)q(eginning)j(with)e Fi(n)p Fp(.)18 b(F)l(rom)10 b(it)g(w)o(e)h(can)f (construct)0 2614 y(an)15 b(in\014nite)i(list)f(of)f(squares:)p eop %%Page: 14 14 bop 0 -40 a Fp(T-14)1513 b Fj(3)45 b(FUNCTIONS)71 160 y Fi(squares)404 b(=)24 b(map)f(\(^2\))h(\(numsfrom)e(0\))0 271 y Fp(\(Note)15 b(the)g(use)g(of)g(a)g(section;)g Fi(^)g Fp(is)h(the)f(in\014x)i(exp)q(onen)o (tiation)f(op)q(erator.\))71 353 y(Of)c(course,)h(ev)o(en)o(tually)g(w)o(e)f (exp)q(ect)i(to)d(extract)h(some)g(\014nite)i(p)q(ortion)e(of)g(the)h(list)g (for)f(actual)g(computation,)0 409 y(and)17 b(there)f(are)h(lots)f(of)g (prede\014ned)j(functions)e(in)h(Hask)o(ell)f(that)f(do)g(this)i(sort)d(of)h (thing:)24 b Fi(take)o Fp(,)17 b Fi(takeWhile)n Fp(,)0 466 y Fi(filter)o Fp(,)g(and)h(others)f(\(see)g(the)g(p)q(ortion)h(of)e(the)i (Standard)f(Prelude)h(called)h Fi(PreludeList)n Fp(\).)26 b(F)l(or)16 b(example,)0 522 y Fi(take)f Fp(remo)o(v)o(es)f(the)h(\014rst)g Fi(n)g Fp(elemen)o(ts)h(from)e(a)h(list:)569 625 y Fi(take)23 b(5)h(squares)72 b Fn(\))i Fi([0,1,4,9,16])71 753 y Fp(The)14 b(de\014nition)i(of)d Fi(ones)g Fp(ab)q(o)o(v)o(e)h(is)h(an)e(example)i(of)f (a)f Fo(cir)n(cular)j(list)p Fp(.)i(In)d(most)e(circumstances)i(this)f(has)g (an)0 809 y(imp)q(ortan)o(t)h(impact)h(on)g(e\016ciency)l(,)h(since)g(an)f (implemen)o(tation)h(can)f(b)q(e)h(exp)q(ected)g(to)e(implemen)o(t)i(the)f (list)g(as)0 866 y(a)f(true)g(circular)h(structure,)f(th)o(us)g(sa)o(ving)g (space.)71 947 y(F)l(or)10 b(another)h(example)i(of)e(the)g(use)h(of)f (circularit)o(y)l(,)i(the)f(Fib)q(onacci)h(sequence)f(can)g(b)q(e)g(computed) g(e\016cien)o(tly)0 1004 y(as)j(the)g(follo)o(wing)h(in\014nite)h(sequence:) 71 1113 y Fi(fib)309 b(=)24 b(1)g(:)g(1)f(:)h([)g(a+b)f(|)h(\(a,b\))f(<-)h (zip)f(fib)h(\(tail)f(fib\))g(])0 1222 y Fp(where)e Fi(zip)g Fp(is)g(a)g(Standard)g(Prelude)h(function)g(that)e(returns)h(the)g(pairwise)h (in)o(terlea)o(ving)g(of)e(its)i(t)o(w)o(o)d(list)0 1278 y(argumen)o(ts:)71 1387 y Fi(zip)k(\(x:xs\))g(\(y:ys\))166 b(=)24 b(\(x,y\))f(:)h(zip)f(xs)h(ys) 71 1444 y(zip)47 b(xs)119 b(ys)238 b(=)24 b([])0 1553 y Fp(Note)16 b(ho)o(w)g Fi(fib)o Fp(,)g(an)h(in\014nite)h(list,)f(is)f(de\014ned)i(in)f (terms)f(of)g(itself,)h(as)e(if)i(it)g(w)o(ere)f(\\c)o(hasing)g(its)g(tail.") 24 b(Indeed,)0 1609 y(w)o(e)15 b(can)g(dra)o(w)g(a)g(picture)h(of)f(this)g (computation)g(as)g(sho)o(wn)g(in)h(Figure)g(1a.)71 1691 y(F)l(or)e(another)h (application)i(of)e(in\014nite)i(lists,)e(see)h(Section)g(4.4.)0 1839 y Fg(3.5)56 b(The)18 b(Error)g(F)-5 b(unction)0 1950 y Fp(Hask)o(ell)20 b(has)f(a)g(built-in)i(function)f(called)h Fi(error)d Fp(whose)h(t)o(yp)q(e)g(is)h Fi(String->a)o Fp(.)31 b(This)20 b(is)f(a)g(somewhat)g(o)q(dd)0 2007 y(function:)k(F)l(rom)15 b(its)h(t)o(yp)q(e)g(it)h(lo)q(oks)f(as)g(if)h(it)f(is)h(returning)f(a)g(v)m (alue)h(of)f(a)g(p)q(olymorphic)i(t)o(yp)q(e)e(ab)q(out)g(whic)o(h)h(it)0 2063 y(kno)o(ws)e(nothing,)g(since)h(it)g(nev)o(er)f(receiv)o(es)h(a)f(v)m (alue)h(of)f(that)g(t)o(yp)q(e)g(as)g(an)g(argumen)o(t!)71 2145 y(In)h(fact,)f(there)h Fo(is)g Fp(one)g(v)m(alue)h(\\shared")e(b)o(y)h (all)h(t)o(yp)q(es:)k Fn(?)p Fp(.)h(Indeed,)c(seman)o(tically)f(that)e(is)h (exactly)h(what)0 2201 y(v)m(alue)c(is)g(alw)o(a)o(ys)e(returned)h(b)o(y)g Fi(error)f Fp(\(recall)i(that)e(all)i(errors)e(ha)o(v)o(e)h(v)m(alue)h Fn(?)p Fp(\).)19 b(Ho)o(w)o(ev)o(er,)11 b(w)o(e)h(can)g(exp)q(ect)h(that)0 2258 y(a)g(reasonable)g(implemen)o(tation)i(will)g(prin)o(t)e(the)g(string)h (argumen)o(t)e(to)g Fi(error)h Fp(for)f(diagnostic)i(purp)q(oses.)20 b(Th)o(us)0 2314 y(this)e(function)g(is)g(useful)g(when)g(w)o(e)f(wish)h(to)f (terminate)g(a)g(program)g(when)h(something)f(has)g(\\gone)g(wrong.")0 2371 y(F)l(or)e(example,)g(the)h(actual)f(de\014nition)i(of)e Fi(head)f Fp(tak)o(en)h(from)f(the)i(Standard)f(Prelude)h(is:)71 2480 y Fi(head)23 b(\(x:xs\))309 b(=)48 b(x)71 2536 y(head)f([])381 b(=)48 b(error)23 b("head{PreludeList}:)e(head)j([]")p eop %%Page: 15 15 bop 1857 -40 a Fp(T-15)33 869 y @beginspecial 5.156800 @llx 435.382507 @lly 327.294495 @urx 781.187195 @ury 1800 @rwi @setspecial %%BeginDocument: fib.eps /FHIODict 30 dict def FHIODict begin /bdf{bind def}bind def /d{setdash}bdf /h{closepath}bdf /H{}bdf /J{setlinecap}bdf /j{setlinejoin}bdf /M{setmiterlimit}bdf /n{newpath}bdf /N{newpath}bdf /q{gsave}bdf /Q{grestore}bdf /w{setlinewidth}bdf /u{}bdf /U{}bdf /sepdef{ dup where not { FreeHandSepDict } if 3 1 roll exch put }bdf /` {end %. FreeHandDict /-save0- save def pop pop pop pop pop concat userdict begin /showpage {} def 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit [] 0 setdash newpath /languagelevel where {pop languagelevel 1 ne{false setstrokeadjust false setoverprint}if}if } bdf /~ {end -save0- restore FreeHandDict begin }bdf /FreeHandDict 190 dict def FreeHandDict begin /currentpacking where{pop true setpacking}if /xdf{exch def}bdf /ndf{1 index where{pop pop pop}{dup xcheck{bind}if def}ifelse}bdf /min{2 copy gt{exch}if pop}bdf /max{2 copy lt{exch}if pop}bdf /isLino statusdict /product get (Lino) anchorsearch{pop pop true}{pop false}ifelse def /dr{transform .25 sub round .25 add exch .25 sub round .25 add exch itransform}bdf /C{dr curveto}bdf /L{dr lineto}bdf /m{dr moveto}bdf /printerRes gsave matrix defaultmatrix setmatrix 72 72 dtransform abs exch abs max grestore def /maxsteps 256 def /calcgraysteps { currentscreen pop exch printerRes exch div exch 2 copy sin mul round dup mul 3 1 roll cos mul round dup mul add 1 add dup maxsteps gt {pop maxsteps} if } bdf /bottom -0 def /delta -0 def /frac -0 def /left -0 def /numsteps -0 def /numsteps1 -0 def /radius -0 def /right -0 def /top -0 def /xt -0 def /yt -0 def /df currentflat def /tempstr 1 string def /clipflatness currentflat def /inverted? 0 currenttransfer exec .5 ge def /colorexists systemdict/setcmykcolor known def /tc1 [0 0 0 1] def /tc2 [0 0 0 1] def /fc [0 0 0 1] def /sc [0 0 0 1] def /concatprocs{ /proc2 exch cvlit def/proc1 exch cvlit def /newproc proc1 length proc2 length add array def newproc 0 proc1 putinterval newproc proc1 length proc2 putinterval newproc cvx}bdf /storerect{/top xdf/right xdf/bottom xdf/left xdf}bdf /rectpath{newpath left bottom m left top L right top L right bottom L closepath}bdf /i{dup 0 eq {pop df dup} {dup} ifelse /clipflatness xdf setflat }bdf version cvr 38.0 le {/setrgbcolor{ currenttransfer exec 3 1 roll currenttransfer exec 3 1 roll currenttransfer exec 3 1 roll setrgbcolor}bdf}if /gettint{0 get}bdf /puttint{0 exch put}bdf /vms {/vmsv save def} bdf /vmr {vmsv restore} bdf /vmrs{vmsv restore /vmsv save def}bdf /eomode{ {/filler /eofill load def /clipper /eoclip load def} {/filler /fill load def /clipper /clip load def} ifelse }bdf /CD{/NF exch def{exch dup/FID ne 1 index/UniqueID ne and{exch NF 3 1 roll put} {pop pop}ifelse}forall NF}bdf /MN{1 index length/Len exch def dup length Len add string dup Len 4 -1 roll putinterval dup 0 4 -1 roll putinterval}bdf /RC{4 -1 roll /ourvec xdf 256 string cvs(|______)anchorsearch {1 index MN cvn/NewN exch def cvn findfont dup maxlength dict CD dup/FontName NewN put dup /Encoding ourvec put NewN exch definefont pop}{pop}ifelse}bdf /RF{dup FontDirectory exch known{pop 3 -1 roll pop}{RC}ifelse}bdf /FF{dup 256 string cvs(|______)exch MN cvn dup FontDirectory exch known {exch pop findfont 3 -1 roll pop}{pop dup findfont dup maxlength dict CD dup dup /Encoding exch /Encoding get 256 array copy 7 -1 roll {3 -1 roll dup 4 -2 roll put}forall put definefont}ifelse}bdf userdict begin /BDFontDict 20 dict def end BDFontDict begin /bu{}def /bn{}def /setTxMode{av 70 ge{pop}if pop}def /gm{m}def /show{pop}def /gr{pop}def /fnt{pop pop pop}def /fs{pop}def /fz{pop}def /lin{pop pop}def end /MacVec 256 array def MacVec 0 /Helvetica findfont /Encoding get 0 128 getinterval putinterval MacVec 127 /DEL put MacVec 16#27 /quotesingle put MacVec 16#60 /grave put /NUL/SOH/STX/ETX/EOT/ENQ/ACK/BEL/BS/HT/LF/VT/FF/CR/SO/SI /DLE/DC1/DC2/DC3/DC4/NAK/SYN/ETB/CAN/EM/SUB/ESC/FS/GS/RS/US MacVec 0 32 getinterval astore pop /Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis/Udieresis/aacute /agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute/egrave /ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde/oacute /ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex/udieresis /dagger/degree/cent/sterling/section/bullet/paragraph/germandbls /register/copyright/trademark/acute/dieresis/notequal/AE/Oslash /infinity/plusminus/lessequal/greaterequal/yen/mu/partialdiff/summation /product/pi/integral/ordfeminine/ordmasculine/Omega/ae/oslash /questiondown/exclamdown/logicalnot/radical/florin/approxequal/Delta/guillemotleft /guillemotright/ellipsis/nbspace/Agrave/Atilde/Otilde/OE/oe /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide/lozenge /ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright/fi/fl /daggerdbl/periodcentered/quotesinglbase/quotedblbase /perthousand/Acircumflex/Ecircumflex/Aacute /Edieresis/Egrave/Iacute/Icircumflex/Idieresis/Igrave/Oacute/Ocircumflex /apple/Ograve/Uacute/Ucircumflex/Ugrave/dotlessi/circumflex/tilde /macron/breve/dotaccent/ring/cedilla/hungarumlaut/ogonek/caron MacVec 128 128 getinterval astore pop /fps{ currentflat exch dup 0 le{pop 1}if { dup setflat 3 index stopped {1.3 mul dup 3 index gt{pop setflat pop pop stop}if} {exit} ifelse }loop pop setflat pop pop }bdf /fp{100 currentflat fps}bdf /clipper{clip}bdf /W{/clipper load 100 clipflatness fps}bdf /fixtrans1 { dup{ic mul ic sub 1 add}concatprocs exch dup{im mul im sub 1 add}concatprocs exch dup{iy mul iy sub 1 add}concatprocs exch {ik mul ik sub 1 add}concatprocs }bdf /fixtrans2 { currentcolortransfer 5 -1 roll exch concatprocs 7 1 roll 4 -1 roll exch concatprocs 6 1 roll 3 -1 roll exch concatprocs 5 1 roll concatprocs 4 1 roll setcolortransfer }bdf end%. FreeHandDict end%. FHIODict FHIODict begin FreeHandDict begin 5.1568 435.3825 327.2945 781.1872 storerect rectpath clip newpath /onlyk{false}ndf /ccmyk{dup 5 -1 roll sub 0 max exch}ndf /setcmykcolor{1 exch sub ccmyk ccmyk ccmyk pop setrgbcolor}ndf /setcmykcoloroverprint{4{dup -1 eq{pop 0}if 4 1 roll}repeat setcmykcolor}ndf /findcmykcustomcolor{5 /packedarray where{pop packedarray}{array astore readonly}ifelse}ndf /setcustomcolor{exch aload pop pop 4{4 index mul 4 1 roll}repeat setcmykcolor pop}ndf /setseparationgray{1 exch sub dup dup dup setcmykcolor}ndf /setoverprint{pop}ndf /currentoverprint false ndf /colorimage{pop pop [5 -1 roll/exec cvx 6 -1 roll/exec cvx 7 -1 roll/exec cvx 8 -1 roll/exec cvx /cmykbufs2gray cvx]cvx image} version cvr 47.1 le isLino and{userdict begin bdf end}{ndf}ifelse /cci1 { currentcolortransfer {ik mul ik sub 1 add}concatprocs 4 1 roll {iy mul iy sub 1 add}concatprocs 4 1 roll {im mul im sub 1 add}concatprocs 4 1 roll {ic mul ic sub 1 add}concatprocs 4 1 roll setcolortransfer }ndf /cci2 { {invbuf dup length magentabuf length ne {dup length dup dup /magentabuf exch string def /yellowbuf exch string def /blackbuf exch string def}if dup magentabuf copy yellowbuf copy blackbuf copy pop}concatprocs }ndf /customcolorimage{colorexists{ aload pop pop 4 array astore setimagecmyk cci1 /magentabuf 0 string def /yellowbuf 0 string def /blackbuf 0 string def cci2 {magentabuf}{yellowbuf}{blackbuf}true 4 colorimage} {pop image}ifelse}ndf /separationimage{image}ndf /newcmykcustomcolor{6 /packedarray where{pop packedarray}{array astore readonly}ifelse}ndf /inkoverprint false ndf /setinkoverprint{pop}ndf /overprintprocess{pop}ndf /setspotcolor {spots exch get 0 5 getinterval exch setcustomcolor}ndf /currentcolortransfer{currenttransfer dup dup dup}ndf /setcolortransfer{systemdict begin settransfer end pop pop pop}ndf /getcmyk { dup length 4 eq {aload pop} {aload pop spots exch get 0 4 getinterval aload pop 4 {4 index mul 4 1 roll}repeat 5 -1 roll pop} ifelse }bdf /setimagecmyk{ getcmyk/ik xdf /iy xdf /im xdf /ic xdf }ndf /autospread{pop}ndf /fhsetspreadsize{pop}ndf /strokeopf false def /fillopf false def /R{0 ne /strokeopf xdf}bdf /O{0 ne /fillopf xdf}bdf /filler{fill}bdf /F{fc fhsetcolor fillopf setoverprint false autospread gsave /filler load fp grestore false setoverprint}bdf /f{closepath F}bdf /S{sc fhsetcolor strokeopf setoverprint true autospread {stroke}fp false setoverprint}bdf /s{closepath S}bdf /B{fc fhsetcolor fillopf setoverprint gsave /filler load fp grestore sc fhsetcolor strokeopf setoverprint true autospread {stroke}fp false setoverprint}bdf /b{closepath B}bdf colorexists not{/setcolorscreen {setscreen pop pop pop pop pop pop pop pop pop}bdf}if /fhsetcolor{dup length 4 eq {aload overprintprocess setcmykcolor} {aload 1 get spots exch get 5 get setinkoverprint setspotcolor} ifelse }ndf /settextcolor{dup fhsetcolor dup length 4 eq {onlyk{3 get 1.0 eq{true setinkoverprint}if}{pop}ifelse} {pop} ifelse }ndf /ka{/fc xdf}bdf /Ka{/sc xdf}bdf /xa{/fc xdf} bdf /Xa{/sc xdf} bdf /bc2[0 0]def /bc4[0 0 0 0]def /absmax{2 copy abs exch abs gt{exch}if pop}bdf /calcstep { colorexists not and{calcgraysteps}{maxsteps}ifelse tc1 length 4 eq { 0 1 3 {tc1 1 index get tc2 3 -1 roll get sub }for absmax absmax absmax } { bc2 tc1 1 get 1 exch put tc1 gettint tc2 gettint sub abs } ifelse mul abs round dup 0 eq{pop 1}if dup /numsteps xdf 1 sub dup 0 eq{pop 1}if /numsteps1 xdf }bdf /cblend{ tc1 length 4 eq { 0 1 3 {bc4 exch tc1 1 index get tc2 2 index get 1 index sub frac mul add put }for bc4 } { bc2 tc1 gettint tc2 gettint 1 index sub frac mul add puttint bc2 } ifelse fhsetcolor }bdf /logtaper{/frac frac 9 mul 1 add log def}bdf FHIODict begin /origmtx matrix currentmatrix def /iminv false def /invbuf{0 1 2 index length 1 sub{dup 2 index exch get 255 exch sub 2 index 3 1 roll put}for}bdf /cyanrp{currentfile cyanbuf readhexstring pop iminv{invbuf}if}def /magentarp{cyanbuf magentabuf copy}bdf /yellowrp{cyanbuf yellowbuf copy}bdf /blackrp{cyanbuf blackbuf copy}bdf /fixtransfer{ colorexists {fixtrans1 fixtrans2} {{dup 1 exch sub currentgray mul add}concatprocs currenttransfer exch concatprocs systemdict begin settransfer end}ifelse }ndf /cmykbufs2gray{ dup length 0 1 3 -1 roll 1 sub {4 index 1 index get 4 index 2 index get 4 index 3 index get 4 index 4 index get 255 exch sub ccmyk ccmyk ccmyk pop 5 mul exch 45 mul add exch 14 mul add -6 bitshift 2 index 3 1 roll put}for 4 1 roll pop pop pop }bdf end /textopf false def /curtextmtx{}def /otw .25 def /msf{dup/curtextmtx xdf makefont setfont}bdf /makesetfont/msf load def /curtextheight{.707104 .707104 curtextmtx dtransform dup mul exch dup mul add sqrt}bdf /ta{1 index {tempstr 0 2 index put tempstr 2 index gsave exec grestore tempstr stringwidth rmoveto 5 index eq{6 index 6 index rmoveto}if 3 index 3 index rmoveto }forall 7{pop}repeat}bdf /sts{settextcolor textopf setoverprint/ts{awidthshow}def exec false setoverprint}bdf /stol{setlinewidth settextcolor textopf setoverprint newpath /ts{{false charpath stroke}ta}def exec false setoverprint}bdf /currentpacking where{pop false setpacking}if /spots[1 0 0 0 (Process Cyan) false newcmykcustomcolor 0 1 0 0 (Process Magenta) false newcmykcustomcolor 0 0 1 0 (Process Yellow) false newcmykcustomcolor 0 0 0 1 (Process Black) false newcmykcustomcolor 0 0 0 0 (White) false newcmykcustomcolor ]def 0 dict dup begin end /f0 /Symbol FF def [] 0 d 3.863708 M 1 w 0 j 0 J 0 O 0 R 0 i false eomode [0 0 0 1] Ka [0 0 0 1] ka vms u vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [18 0 0 18 0 0] makesetfont 9.656845 613.020248 m 0 0 32 0 0 (1) ts } [0 0 0 1] sts 78.6568 699.0202 m 78.6568 745.0202 L 2 J S 78.6568 745.0202 m 83.6568 745.0202 L 78.6568 757.0202 L 73.6568 745.0202 L 78.6568 745.0202 L f n 160.6568 624.0202 m 162.6568 627.0202 L 165.6568 631.0202 L 168.6568 634.0202 L 171.6568 636.0202 L 175.6568 639.0202 L 178.6568 641.0202 L 180.6568 642.0202 L 182.6568 643.0202 L 184.6568 644.0202 L 186.6568 645.0202 L 188.6568 646.0202 L 190.6568 647.0202 L 192.6568 647.0202 L 194.6568 648.0202 L 196.6568 648.0202 L 198.6568 649.0202 L 200.6568 649.0202 L 202.6568 650.0202 L 205.6568 650.0202 L 207.6568 650.0202 L 209.6568 650.0202 L 211.6568 651.0202 L 213.6568 651.0202 L 215.6568 651.0202 L 217.6568 650.0202 L 219.6568 650.0202 L 221.6568 650.0202 L 223.6568 650.0202 L 225.6568 649.0202 L 227.6568 649.0202 L 231.6568 648.0202 L 235.6568 646.0202 L 238.6568 644.0202 L 241.6568 642.0202 L 244.6568 640.0202 L 247.6568 637.0202 L 249.6568 635.0202 L 251.6568 632.0202 L 253.6568 630.0202 L 255.6568 628.0202 L 257.6568 625.0202 L 258.6568 623.0202 L 260.6568 621.0202 L 262.6568 618.0202 L 263.6568 616.0202 L 265.6568 613.0202 L 267.6568 611.0202 L 268.6568 608.0202 L 270.6568 606.0202 L 271.6568 603.0202 L 272.6568 601.0202 L 274.6568 598.0202 L 275.6568 595.0202 L 276.6568 593.0202 L 277.6568 590.0202 L 279.6568 588.0202 L 280.6568 585.0202 L 281.6568 582.0202 L 282.6568 580.0202 L 283.6568 577.0202 L 284.6568 574.0202 L 285.6568 572.0202 L 286.6568 569.0202 L 286.6568 566.0202 L 287.6568 563.0202 L 288.6568 561.0202 L 289.6568 558.0202 L 289.6568 555.0202 L 290.6568 552.0202 L 291.6568 550.0202 L 291.6568 547.0202 L 292.6568 544.0202 L 292.6568 541.0202 L 293.6568 538.0202 L 293.6568 536.0202 L 293.6568 533.0202 L 294.6568 530.0202 L 294.6568 527.0202 L 294.6568 524.0202 L 295.6568 521.0202 L 295.6568 519.0202 L 295.6568 516.0202 L 295.6568 513.0202 L 295.6568 510.0202 L 295.6568 506.0202 L 295.6568 503.0202 L 295.6568 500.0202 L 294.6568 498.0202 L 294.6568 495.0202 L 293.6568 493.0202 L 293.6568 491.0202 L 292.6568 489.0202 L 291.6568 487.0202 L 290.6568 486.0202 L 289.6568 484.0202 L 288.6568 483.0202 L 286.6568 481.0202 L 284.6568 480.0202 L 281.6568 481.0202 L 279.6568 481.0202 L 276.6568 482.0202 L 274.6568 484.0202 L 235.6568 520.0202 L S 91.6568 694.0202 m 93.6568 696.0202 L 95.6568 698.0202 L 97.6568 700.0202 L 100.6568 702.0202 L 102.6568 703.0202 L 104.6568 705.0202 L 107.6568 706.0202 L 109.6568 708.0202 L 112.6568 709.0202 L 114.6568 710.0202 L 117.6568 711.0202 L 119.6568 713.0202 L 122.6568 714.0202 L 125.6568 715.0202 L 128.6568 715.0202 L 130.6568 716.0202 L 133.6568 717.0202 L 136.6568 718.0202 L 139.6568 718.0202 L 142.6568 719.0202 L 145.6568 719.0202 L 148.6568 720.0202 L 151.6568 720.0202 L 154.6568 720.0202 L 156.6568 720.0202 L 159.6568 720.0202 L 162.6568 720.0202 L 165.6568 720.0202 L 168.6568 720.0202 L 171.6568 720.0202 L 174.6568 720.0202 L 177.6568 720.0202 L 180.6568 720.0202 L 183.6568 719.0202 L 186.6568 719.0202 L 189.6568 719.0202 L 192.6568 718.0202 L 195.6568 718.0202 L 198.6568 717.0202 L 201.6568 716.0202 L 203.6568 716.0202 L 206.6568 715.0202 L 209.6568 714.0202 L 212.6568 714.0202 L 214.6568 713.0202 L 217.6568 712.0202 L 220.6568 711.0202 L 222.6568 710.0202 L 225.6568 709.0202 L 228.6568 707.0202 L 232.6568 706.0202 L 235.6568 704.0202 L 238.6568 703.0202 L 241.6568 701.0202 L 244.6568 699.0202 L 246.6568 697.0202 L 249.6568 695.0202 L 252.6568 693.0202 L 255.6568 691.0202 L 257.6568 689.0202 L 260.6568 687.0202 L 262.6568 684.0202 L 265.6568 682.0202 L 267.6568 679.0202 L 270.6568 677.0202 L 272.6568 674.0202 L 274.6568 672.0202 L 276.6568 669.0202 L 278.6568 666.0202 L 280.6568 663.0202 L 282.6568 660.0202 L 284.6568 657.0202 L 286.6568 655.0202 L 288.6568 652.0202 L 290.6568 649.0202 L 292.6568 646.0202 L 294.6568 642.0202 L 295.6568 639.0202 L 297.6568 636.0202 L 298.6568 633.0202 L 300.6568 630.0202 L 301.6568 626.0202 L 303.6568 623.0202 L 304.6568 620.0202 L 305.6568 617.0202 L 307.6568 613.0202 L 308.6568 610.0202 L 309.6568 607.0202 L 310.6568 603.0202 L 311.6568 600.0202 L 312.6568 597.0202 L 313.6568 593.0202 L 314.6568 590.0202 L 315.6568 587.0202 L 315.6568 583.0202 L 316.6568 580.0202 L 316.6568 578.0202 L 317.6568 575.0202 L 318.6568 573.0202 L 318.6568 570.0202 L 319.6568 567.0202 L 319.6568 564.0202 L 320.6568 562.0202 L 320.6568 559.0202 L 321.6568 556.0202 L 321.6568 553.0202 L 322.6568 550.0202 L 322.6568 547.0202 L 323.6568 544.0202 L 323.6568 541.0202 L 324.6568 538.0202 L 324.6568 534.0202 L 324.6568 531.0202 L 325.6568 528.0202 L 325.6568 525.0202 L 325.6568 522.0202 L 325.6568 519.0202 L 326.6568 515.0202 L 326.6568 512.0202 L 326.6568 509.0202 L 326.6568 506.0202 L 326.6568 503.0202 L 325.6568 500.0202 L 325.6568 497.0202 L 325.6568 494.0202 L 324.6568 491.0202 L 324.6568 488.0202 L 323.6568 486.0202 L 323.6568 483.0202 L 322.6568 480.0202 L 321.6568 477.0202 L 320.6568 475.0202 L 319.6568 472.0202 L 318.6568 470.0202 L 317.6568 468.0202 L 315.6568 466.0202 L 314.6568 464.0202 L 312.6568 462.0202 L 311.6568 460.0202 L 309.6568 458.0202 L 307.6568 456.0202 L 305.6568 455.0202 L 302.6568 453.0202 L 300.6568 452.0202 L 297.6568 451.0202 L 294.6568 449.0202 L 291.6568 448.0202 L 288.6568 447.0202 L 285.6568 446.0202 L 282.6568 445.0202 L 279.6568 444.0202 L 276.6568 443.0202 L 273.6568 442.0202 L 270.6568 441.0202 L 267.6568 440.0202 L 263.6568 439.0202 L 260.6568 439.0202 L 257.6568 438.0202 L 253.6568 438.0202 L 250.6568 437.0202 L 247.6568 437.0202 L 244.6568 437.0202 L 240.6568 436.0202 L 237.6568 436.0202 L 234.6568 436.0202 L 230.6568 436.0202 L 227.6568 436.0202 L 224.6568 436.0202 L 221.6568 436.0202 L 218.6568 437.0202 L 214.6568 437.0202 L 211.6568 437.0202 L 208.6568 438.0202 L 205.6568 439.0202 L 202.6568 439.0202 L 199.6568 440.0202 L 196.6568 441.0202 L 194.6568 442.0202 L 191.6568 443.0202 L 188.6568 444.0202 L 185.6568 445.0202 L 183.6568 447.0202 L 180.6568 448.0202 L 178.6568 450.0202 L 176.6568 451.0202 L 173.6568 453.0202 L 171.6568 455.0202 L 169.6568 456.0202 L 167.6568 458.0202 L 165.6568 461.0202 L 164.6568 463.0202 L 162.6568 465.0202 L 161.6568 467.0202 L 160.6568 469.0202 L 160.6568 471.0202 L 160.6568 473.0202 L 160.6568 476.0202 L 160.6568 478.0202 L 161.6568 481.0202 L 162.6568 483.0202 L 163.6568 486.0202 L 165.6568 488.0202 L 166.6568 491.0202 L 168.6568 494.0202 L 170.6568 496.0202 L 172.6568 499.0202 L 174.6568 502.0202 L 177.6568 505.0202 L 179.6568 507.0202 L 181.6568 510.0202 L 184.6568 513.0202 L 186.6568 515.0202 L 188.6568 518.0202 L 191.6568 520.0202 L 193.6568 523.0202 L 195.6568 525.0202 L S u 134.6568 623.0202 m 101.6568 657.0202 L S 101.6568 657.0202 m 105.6568 661.0202 L 93.6568 666.0202 L 98.6568 653.0202 L 101.6568 657.0202 L f n U u 202.6568 554.0202 m 171.6568 586.0202 L S 171.6568 586.0202 m 174.6568 590.0202 L 162.6568 595.0202 L 167.6568 582.0202 L 171.6568 586.0202 L f n U u u 60.1568 680.5202 m 60.1568 691.0138 68.6633 699.5202 79.1568 699.5202 C 89.6504 699.5202 98.1568 691.0138 98.1568 680.5202 C 98.1568 670.0267 89.6504 661.5202 79.1568 661.5202 C 68.6633 661.5202 60.1568 670.0267 60.1568 680.5202 C [0 0 0 0] ka b U vmrs 0 dict dup begin end /f2 /Symbol FF def { f2 [36 0 0 36 0 0] makesetfont 73.656845 672.020248 m 0 0 32 0 0 (:) ts } [0 0 0 1] sts U u u 129.1568 610.5202 m 129.1568 621.0138 137.6633 629.5202 148.1568 629.5202 C 158.6504 629.5202 167.1568 621.0138 167.1568 610.5202 C 167.1568 600.0267 158.6504 591.5202 148.1568 591.5202 C 137.6633 591.5202 129.1568 600.0267 129.1568 610.5202 C [0 0 0 0] ka 2 J b U vmrs 0 dict dup begin end /f2 /Symbol FF def { f2 [36 0 0 36 0 0] makesetfont 142.656845 602.020248 m 0 0 32 0 0 (:) ts } [0 0 0 1] sts U u 199.1568 541.5202 m 199.1568 552.0138 207.6633 560.5202 218.1568 560.5202 C 228.6504 560.5202 237.1568 552.0138 237.1568 541.5202 C 237.1568 531.0267 228.6504 522.5202 218.1568 522.5202 C 207.6633 522.5202 199.1568 531.0267 199.1568 541.5202 C [0 0 0 0] ka 2 J b U vmrs 0 dict dup begin end /f2 /Symbol FF def { f2 [36 0 0 36 0 0] makesetfont 208.12738 532.080994 m 0 0 32 0 0 (+) ts } [0 0 0 1] sts u 22.6568 624.0202 m 55.6568 658.0202 L 2 J S 55.6568 658.0202 m 58.6568 654.0202 L 63.6568 667.0202 L 51.6568 662.0202 L 55.6568 658.0202 L f n U u 90.6568 551.0202 m 123.6568 585.0202 L S 123.6568 585.0202 m 126.6568 581.0202 L 131.6568 594.0202 L 119.6568 589.0202 L 123.6568 585.0202 L f n U u 192.6568 520.0202 m 191.6568 519.0202 L S 191.6568 519.0202 m 195.6568 515.0202 L 200.6568 528.0202 L 187.6568 523.0202 L 191.6568 519.0202 L f n U u 237.6568 518.0202 m 240.6568 515.0202 L S 240.6568 515.0202 m 244.6568 519.0202 L 231.6568 524.0202 L 236.6568 511.0202 L 240.6568 515.0202 L f n U vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [18 0 0 18 0 0] makesetfont 76.656845 538.020248 m 0 0 32 0 0 (1) ts } [0 0 0 1] sts vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [18 0 0 18 0 0] makesetfont 126.656845 724.020248 m 0 0 32 0 0 (1,1,2,3,5,...) ts } [0 0 0 1] sts vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [18 0 0 18 0 0] makesetfont 164.656845 655.020248 m 0 0 32 0 0 (1,2,3,5,8,...) ts } [0 0 0 1] sts vmrs MacVec 256 array copy /f3 /|______Times-BoldItalic dup RF findfont def { f3 [18 0 0 18 0 0] makesetfont 69.656845 763.020248 m 0 0 32 0 0 (fib) ts } [0 0 0 1] sts U vmr end % FreeHandDict end % FHIODict %%EndDocument @endspecial 1134 w @beginspecial 14.258400 @llx 620.398376 @lly 377.258392 @urx 783.398376 @ury 1800 @rwi @setspecial %%BeginDocument: io.eps /FHIODict 30 dict def FHIODict begin /bdf{bind def}bind def /d{setdash}bdf /h{closepath}bdf /H{}bdf /J{setlinecap}bdf /j{setlinejoin}bdf /M{setmiterlimit}bdf /n{newpath}bdf /N{newpath}bdf /q{gsave}bdf /Q{grestore}bdf /w{setlinewidth}bdf /u{}bdf /U{}bdf /sepdef{ dup where not { FreeHandSepDict } if 3 1 roll exch put }bdf /` {end %. FreeHandDict /-save0- save def pop pop pop pop pop concat userdict begin /showpage {} def 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit [] 0 setdash newpath /languagelevel where {pop languagelevel 1 ne{false setstrokeadjust false setoverprint}if}if } bdf /~ {end -save0- restore FreeHandDict begin }bdf /FreeHandDict 190 dict def FreeHandDict begin /currentpacking where{pop true setpacking}if /xdf{exch def}bdf /ndf{1 index where{pop pop pop}{dup xcheck{bind}if def}ifelse}bdf /min{2 copy gt{exch}if pop}bdf /max{2 copy lt{exch}if pop}bdf /isLino statusdict /product get (Lino) anchorsearch{pop pop true}{pop false}ifelse def /dr{transform .25 sub round .25 add exch .25 sub round .25 add exch itransform}bdf /C{dr curveto}bdf /L{dr lineto}bdf /m{dr moveto}bdf /printerRes gsave matrix defaultmatrix setmatrix 72 72 dtransform abs exch abs max grestore def /maxsteps 256 def /calcgraysteps { currentscreen pop exch printerRes exch div exch 2 copy sin mul round dup mul 3 1 roll cos mul round dup mul add 1 add dup maxsteps gt {pop maxsteps} if } bdf /bottom -0 def /delta -0 def /frac -0 def /left -0 def /numsteps -0 def /numsteps1 -0 def /radius -0 def /right -0 def /top -0 def /xt -0 def /yt -0 def /df currentflat def /tempstr 1 string def /clipflatness currentflat def /inverted? 0 currenttransfer exec .5 ge def /colorexists systemdict/setcmykcolor known def /tc1 [0 0 0 1] def /tc2 [0 0 0 1] def /fc [0 0 0 1] def /sc [0 0 0 1] def /concatprocs{ /proc2 exch cvlit def/proc1 exch cvlit def /newproc proc1 length proc2 length add array def newproc 0 proc1 putinterval newproc proc1 length proc2 putinterval newproc cvx}bdf /storerect{/top xdf/right xdf/bottom xdf/left xdf}bdf /rectpath{newpath left bottom m left top L right top L right bottom L closepath}bdf /i{dup 0 eq {pop df dup} {dup} ifelse /clipflatness xdf setflat }bdf version cvr 38.0 le {/setrgbcolor{ currenttransfer exec 3 1 roll currenttransfer exec 3 1 roll currenttransfer exec 3 1 roll setrgbcolor}bdf}if /gettint{0 get}bdf /puttint{0 exch put}bdf /vms {/vmsv save def} bdf /vmr {vmsv restore} bdf /vmrs{vmsv restore /vmsv save def}bdf /eomode{ {/filler /eofill load def /clipper /eoclip load def} {/filler /fill load def /clipper /clip load def} ifelse }bdf /CD{/NF exch def{exch dup/FID ne 1 index/UniqueID ne and{exch NF 3 1 roll put} {pop pop}ifelse}forall NF}bdf /MN{1 index length/Len exch def dup length Len add string dup Len 4 -1 roll putinterval dup 0 4 -1 roll putinterval}bdf /RC{4 -1 roll /ourvec xdf 256 string cvs(|______)anchorsearch {1 index MN cvn/NewN exch def cvn findfont dup maxlength dict CD dup/FontName NewN put dup /Encoding ourvec put NewN exch definefont pop}{pop}ifelse}bdf /RF{dup FontDirectory exch known{pop 3 -1 roll pop}{RC}ifelse}bdf /FF{dup 256 string cvs(|______)exch MN cvn dup FontDirectory exch known {exch pop findfont 3 -1 roll pop}{pop dup findfont dup maxlength dict CD dup dup /Encoding exch /Encoding get 256 array copy 7 -1 roll {3 -1 roll dup 4 -2 roll put}forall put definefont}ifelse}bdf userdict begin /BDFontDict 20 dict def end BDFontDict begin /bu{}def /bn{}def /setTxMode{av 70 ge{pop}if pop}def /gm{m}def /show{pop}def /gr{pop}def /fnt{pop pop pop}def /fs{pop}def /fz{pop}def /lin{pop pop}def end /MacVec 256 array def MacVec 0 /Helvetica findfont /Encoding get 0 128 getinterval putinterval MacVec 127 /DEL put MacVec 16#27 /quotesingle put MacVec 16#60 /grave put /NUL/SOH/STX/ETX/EOT/ENQ/ACK/BEL/BS/HT/LF/VT/FF/CR/SO/SI /DLE/DC1/DC2/DC3/DC4/NAK/SYN/ETB/CAN/EM/SUB/ESC/FS/GS/RS/US MacVec 0 32 getinterval astore pop /Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis/Udieresis/aacute /agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute/egrave /ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde/oacute /ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex/udieresis /dagger/degree/cent/sterling/section/bullet/paragraph/germandbls /register/copyright/trademark/acute/dieresis/notequal/AE/Oslash /infinity/plusminus/lessequal/greaterequal/yen/mu/partialdiff/summation /product/pi/integral/ordfeminine/ordmasculine/Omega/ae/oslash /questiondown/exclamdown/logicalnot/radical/florin/approxequal/Delta/guillemotleft /guillemotright/ellipsis/nbspace/Agrave/Atilde/Otilde/OE/oe /endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide/lozenge /ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright/fi/fl /daggerdbl/periodcentered/quotesinglbase/quotedblbase /perthousand/Acircumflex/Ecircumflex/Aacute /Edieresis/Egrave/Iacute/Icircumflex/Idieresis/Igrave/Oacute/Ocircumflex /apple/Ograve/Uacute/Ucircumflex/Ugrave/dotlessi/circumflex/tilde /macron/breve/dotaccent/ring/cedilla/hungarumlaut/ogonek/caron MacVec 128 128 getinterval astore pop /fps{ currentflat exch dup 0 le{pop 1}if { dup setflat 3 index stopped {1.3 mul dup 3 index gt{pop setflat pop pop stop}if} {exit} ifelse }loop pop setflat pop pop }bdf /fp{100 currentflat fps}bdf /clipper{clip}bdf /W{/clipper load 100 clipflatness fps}bdf /fixtrans1 { dup{ic mul ic sub 1 add}concatprocs exch dup{im mul im sub 1 add}concatprocs exch dup{iy mul iy sub 1 add}concatprocs exch {ik mul ik sub 1 add}concatprocs }bdf /fixtrans2 { currentcolortransfer 5 -1 roll exch concatprocs 7 1 roll 4 -1 roll exch concatprocs 6 1 roll 3 -1 roll exch concatprocs 5 1 roll concatprocs 4 1 roll setcolortransfer }bdf end%. FreeHandDict end%. FHIODict FHIODict begin FreeHandDict begin 14.2584 620.3984 377.2584 783.3984 storerect rectpath clip newpath /onlyk{false}ndf /ccmyk{dup 5 -1 roll sub 0 max exch}ndf /setcmykcolor{1 exch sub ccmyk ccmyk ccmyk pop setrgbcolor}ndf /setcmykcoloroverprint{4{dup -1 eq{pop 0}if 4 1 roll}repeat setcmykcolor}ndf /findcmykcustomcolor{5 /packedarray where{pop packedarray}{array astore readonly}ifelse}ndf /setcustomcolor{exch aload pop pop 4{4 index mul 4 1 roll}repeat setcmykcolor pop}ndf /setseparationgray{1 exch sub dup dup dup setcmykcolor}ndf /setoverprint{pop}ndf /currentoverprint false ndf /colorimage{pop pop [5 -1 roll/exec cvx 6 -1 roll/exec cvx 7 -1 roll/exec cvx 8 -1 roll/exec cvx /cmykbufs2gray cvx]cvx image} version cvr 47.1 le isLino and{userdict begin bdf end}{ndf}ifelse /cci1 { currentcolortransfer {ik mul ik sub 1 add}concatprocs 4 1 roll {iy mul iy sub 1 add}concatprocs 4 1 roll {im mul im sub 1 add}concatprocs 4 1 roll {ic mul ic sub 1 add}concatprocs 4 1 roll setcolortransfer }ndf /cci2 { {invbuf dup length magentabuf length ne {dup length dup dup /magentabuf exch string def /yellowbuf exch string def /blackbuf exch string def}if dup magentabuf copy yellowbuf copy blackbuf copy pop}concatprocs }ndf /customcolorimage{colorexists{ aload pop pop 4 array astore setimagecmyk cci1 /magentabuf 0 string def /yellowbuf 0 string def /blackbuf 0 string def cci2 {magentabuf}{yellowbuf}{blackbuf}true 4 colorimage} {pop image}ifelse}ndf /separationimage{image}ndf /newcmykcustomcolor{6 /packedarray where{pop packedarray}{array astore readonly}ifelse}ndf /inkoverprint false ndf /setinkoverprint{pop}ndf /overprintprocess{pop}ndf /setspotcolor {spots exch get 0 5 getinterval exch setcustomcolor}ndf /currentcolortransfer{currenttransfer dup dup dup}ndf /setcolortransfer{systemdict begin settransfer end pop pop pop}ndf /getcmyk { dup length 4 eq {aload pop} {aload pop spots exch get 0 4 getinterval aload pop 4 {4 index mul 4 1 roll}repeat 5 -1 roll pop} ifelse }bdf /setimagecmyk{ getcmyk/ik xdf /iy xdf /im xdf /ic xdf }ndf /autospread{pop}ndf /fhsetspreadsize{pop}ndf /strokeopf false def /fillopf false def /R{0 ne /strokeopf xdf}bdf /O{0 ne /fillopf xdf}bdf /filler{fill}bdf /F{fc fhsetcolor fillopf setoverprint false autospread gsave /filler load fp grestore false setoverprint}bdf /f{closepath F}bdf /S{sc fhsetcolor strokeopf setoverprint true autospread {stroke}fp false setoverprint}bdf /s{closepath S}bdf /B{fc fhsetcolor fillopf setoverprint gsave /filler load fp grestore sc fhsetcolor strokeopf setoverprint true autospread {stroke}fp false setoverprint}bdf /b{closepath B}bdf colorexists not{/setcolorscreen {setscreen pop pop pop pop pop pop pop pop pop}bdf}if /fhsetcolor{dup length 4 eq {aload overprintprocess setcmykcolor} {aload 1 get spots exch get 5 get setinkoverprint setspotcolor} ifelse }ndf /settextcolor{dup fhsetcolor dup length 4 eq {onlyk{3 get 1.0 eq{true setinkoverprint}if}{pop}ifelse} {pop} ifelse }ndf /ka{/fc xdf}bdf /Ka{/sc xdf}bdf /xa{/fc xdf} bdf /Xa{/sc xdf} bdf /bc2[0 0]def /bc4[0 0 0 0]def /absmax{2 copy abs exch abs gt{exch}if pop}bdf /calcstep { colorexists not and{calcgraysteps}{maxsteps}ifelse tc1 length 4 eq { 0 1 3 {tc1 1 index get tc2 3 -1 roll get sub }for absmax absmax absmax } { bc2 tc1 1 get 1 exch put tc1 gettint tc2 gettint sub abs } ifelse mul abs round dup 0 eq{pop 1}if dup /numsteps xdf 1 sub dup 0 eq{pop 1}if /numsteps1 xdf }bdf /cblend{ tc1 length 4 eq { 0 1 3 {bc4 exch tc1 1 index get tc2 2 index get 1 index sub frac mul add put }for bc4 } { bc2 tc1 gettint tc2 gettint 1 index sub frac mul add puttint bc2 } ifelse fhsetcolor }bdf /logtaper{/frac frac 9 mul 1 add log def}bdf FHIODict begin /origmtx matrix currentmatrix def /iminv false def /invbuf{0 1 2 index length 1 sub{dup 2 index exch get 255 exch sub 2 index 3 1 roll put}for}bdf /cyanrp{currentfile cyanbuf readhexstring pop iminv{invbuf}if}def /magentarp{cyanbuf magentabuf copy}bdf /yellowrp{cyanbuf yellowbuf copy}bdf /blackrp{cyanbuf blackbuf copy}bdf /fixtransfer{ colorexists {fixtrans1 fixtrans2} {{dup 1 exch sub currentgray mul add}concatprocs currenttransfer exch concatprocs systemdict begin settransfer end}ifelse }ndf /cmykbufs2gray{ dup length 0 1 3 -1 roll 1 sub {4 index 1 index get 4 index 2 index get 4 index 3 index get 4 index 4 index get 255 exch sub ccmyk ccmyk ccmyk pop 5 mul exch 45 mul add exch 14 mul add -6 bitshift 2 index 3 1 roll put}for 4 1 roll pop pop pop }bdf end /textopf false def /curtextmtx{}def /otw .25 def /msf{dup/curtextmtx xdf makefont setfont}bdf /makesetfont/msf load def /curtextheight{.707104 .707104 curtextmtx dtransform dup mul exch dup mul add sqrt}bdf /ta{1 index {tempstr 0 2 index put tempstr 2 index gsave exec grestore tempstr stringwidth rmoveto 5 index eq{6 index 6 index rmoveto}if 3 index 3 index rmoveto }forall 7{pop}repeat}bdf /sts{settextcolor textopf setoverprint/ts{awidthshow}def exec false setoverprint}bdf /stol{setlinewidth settextcolor textopf setoverprint newpath /ts{{false charpath stroke}ta}def exec false setoverprint}bdf /currentpacking where{pop false setpacking}if /spots[1 0 0 0 (Process Cyan) false newcmykcustomcolor 0 1 0 0 (Process Magenta) false newcmykcustomcolor 0 0 1 0 (Process Yellow) false newcmykcustomcolor 0 0 0 1 (Process Black) false newcmykcustomcolor 0 0 0 0 (White) false newcmykcustomcolor ]def 0 dict dup begin end /f0 /Symbol FF def [] 0 d 3.863708 M 1 w 0 j 0 J 0 O 0 R 0 i false eomode [0 0 0 1] Ka [0 0 0 1] ka vms u u u u u 14.7584 767.5217 m 119.7584 767.5217 L 119.7584 710.5217 L 14.7584 710.5217 L 14.7584 767.5217 L [0 0 0 0] ka 2 J b U vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [24 0 0 24 0 0] makesetfont 34.258438 731.021698 m 0 0 32 0 0 (client) ts } [0 0 0 1] sts U u 271.7584 767.5217 m 376.7584 767.5217 L 376.7584 710.5217 L 271.7584 710.5217 L 271.7584 767.5217 L [0 0 0 0] ka 2 J b U vmrs MacVec 256 array copy /f1 /|______Helvetica-Bold dup RF findfont def { f1 [24 0 0 24 0 0] makesetfont 286.258438 732.021698 m 0 0 32 0 0 (server) ts } [0 0 0 1] sts u 119.2584 756.0217 m 254.2584 756.0217 L 2 J S 254.2584 756.0217 m 254.2584 751.0217 L 266.2584 756.0217 L 254.2584 761.0217 L 254.2584 756.0217 L f n U u 271.2584 721.0217 m 135.2584 721.0217 L S 135.2584 721.0217 m 135.2584 726.0217 L 123.2584 721.0217 L 135.2584 716.0217 L 135.2584 721.0217 L f n U u 65.2584 653.0217 m 65.2584 694.0217 L S 65.2584 694.0217 m 70.2584 694.0217 L 65.2584 706.0217 L 60.2584 694.0217 L 65.2584 694.0217 L f n U vmrs MacVec 256 array copy /f2 /|______Courier-Bold dup RF findfont def { f2 [24 0 0 24 0 0] makesetfont 163.258438 760.021698 m 0 0 32 0 0 (reqs) ts } [0 0 0 1] sts vmrs MacVec 256 array copy /f2 /|______Courier-Bold dup RF findfont def { f2 [24 0 0 24 0 0] makesetfont 158.258438 705.021698 m 0 0 32 0 0 (resps) ts } [0 0 0 1] sts vmrs MacVec 256 array copy /f2 /|______Courier-Bold dup RF findfont def { f2 [24 0 0 24 0 0] makesetfont 38.258438 633.021698 m 0 0 32 0 0 (init) ts } [0 0 0 1] sts U U U vmr end % FreeHandDict end % FHIODict %%EndDocument @endspecial 106 967 a(Figure)15 b(1:)20 b(\(a\))14 b(Circular)i(Fib)q (onacci)h(Sequence)331 b(\(b\))15 b(Serv)o(er/Clien)o(t)h(Sim)o(ulation)0 1093 y Fq(4)69 b(Case)23 b(Expressions)g(and)h(P)n(attern)f(Matc)n(hing)0 1215 y Fp(Earlier)c(w)o(e)e(ga)o(v)o(e)g(sev)o(eral)h(examples)h(of)e (pattern)h(matc)o(hing)g(in)g(de\014ning)i(functions|for)e(example)h Fi(length)0 1271 y Fp(and)f Fi(fringe)o Fp(.)28 b(In)19 b(this)f(section)g(w) o(e)g(will)h(lo)q(ok)f(at)g(the)g(pattern-matc)o(hing)f(pro)q(cess)h(in)h(m)o (uc)o(h)f(greater)f(detail)0 1328 y(\()p Fn(x)p Fp(3.14\).)151 1311 y Fm(9)71 1404 y Fp(P)o(atterns)e(are)i(not)f(\\\014rst-class;")h(there) g(is)h(only)f(a)g(\014xed)g(set)g(of)f(di\013eren)o(t)i(kinds)f(of)g (patterns.)24 b(W)l(e)17 b(ha)o(v)o(e)0 1461 y(already)c(seen)g(sev)o(eral)g (examples)h(of)e Fo(data)j(c)n(onstructor)e Fp(patterns;)f(b)q(oth)h Fi(length)f Fp(and)h Fi(fringe)f Fp(de\014ned)i(earlier)0 1517 y(use)i(suc)o(h)h(patterns,)e(the)h(former)f(on)h(the)g(constructors)f(of)g (a)h(\\built-in")i(t)o(yp)q(e)e(\(lists\),)g(the)g(latter)f(on)h(a)g(user-)0 1574 y(de\014ned)e(t)o(yp)q(e)e(\()p Fi(Tree)o Fp(\).)19 b(Indeed,)14 b(matc)o(hing)e(is)h(p)q(ermitted)g(using)h(the)e(constructors)g(of)g(an)o(y) g(t)o(yp)q(e,)g(user-de\014ned)0 1630 y(or)19 b(not.)31 b(This)20 b(includes)h(tuples,)g(strings,)f(n)o(um)o(b)q(ers,)g(c)o(haracters,)f(etc.) 32 b(F)l(or)18 b(example,)j(here's)e(a)g(con)o(triv)o(ed)0 1686 y(function)d(that)f(matc)o(hes)f(against)h(a)g(tuple)h(of)f(\\constan)o (ts:")71 1795 y Fi(contrived)22 b(::)i(\([a],)f(Char,)g(\(Int,)g(Float\),)g (String,)g(Bool\))g(->)h(Bool)71 1852 y(contrived)94 b(\([],)47 b('b',)g(\(1,)71 b(2.0\),)g("hi",)g(True\))23 b(=)h(False)0 1964 y Fp(This)16 b(example)g(also)f(demonstrates)f(that)h Fo(nesting)f Fp(of)g(patterns)h(is)h(p)q(ermitted)g(\(to)e(arbitrary)h (depth\).)71 2040 y(T)l(ec)o(hnically)21 b(sp)q(eaking,)f Fo(formal)g(p)n(ar) n(ameters)881 2024 y Fm(10)937 2040 y Fp(are)f(also)f(patterns|it's)h(just)f (that)g(they)h Fo(never)g(fail)h(to)0 2097 y(match)f(a)g(value)p Fp(.)28 b(As)18 b(a)f(\\side)h(e\013ect")g(of)f(the)h(successful)h(matc)o(h,) e(the)h(formal)g(parameter)f(is)h(b)q(ound)h(to)e(the)0 2153 y(v)m(alue)j(it)e(is)h(b)q(eing)h(matc)o(hed)e(against.)30 b(F)l(or)18 b(this)g(reason)h(patterns)e(in)j(an)o(y)e(one)g(equation)h(are)f (not)h(allo)o(w)o(ed)0 2210 y(to)14 b(ha)o(v)o(e)h(more)f(than)h(one)f(o)q (ccurrence)i(of)f(the)g(same)f(formal)g(parameter)g(\(a)h(prop)q(ert)o(y)f (called)i Fo(line)n(arity)e Fn(x)q Fp(3.14,)0 2266 y Fn(x)p Fp(3.2,)p Fn(x)o Fp(4.4.2\).)71 2343 y(P)o(atterns)c(suc)o(h)i(as)e(formal)h (parameters)g(that)g(nev)o(er)g(fail)h(to)f(matc)o(h)g(are)g(said)h(to)e(b)q (e)i Fo(irr)n(efutable)p Fp(,)g(in)g(con)o(trast)0 2399 y(to)g Fo(r)n(efutable)h Fp(patterns)f(suc)o(h)h(as)f(the)h(ones)g(giv)o(en)g(in)h (the)e Fi(contrived)g Fp(example)h(ab)q(o)o(v)o(e.)19 b(There)13 b(are)g(three)f(other)p 0 2434 780 2 v 52 2461 a Fl(9)69 2477 y Fk(P)o(attern)k(matc)o(hing)h(in)f(Hask)o(ell)h(is)f(v)o(ery)g(di\013eren)o (t)h(from)e(that)g(found)h(in)h(logic)g(programming)g(languages)g(suc)o(h)f (as)g(Prolog;)0 2522 y(in)e(particular,)h(it)e(can)g(b)q(e)h(view)o(ed)g(as)f (\\one-w)o(a)o(y")g(matc)o(hing,)h(whereas)g(Prolog)g(allo)o(ws)g(\\t)o(w)o (o-w)o(a)o(y")f(matc)o(hing)i(\(via)e(uni\014cation\),)0 2568 y(along)h(with)g(implicit)i(bac)o(ktrac)o(king)f(in)f(its)f(ev)n(aluation)j (mec)o(hanism.)37 2598 y Fl(10)69 2614 y Fk(The)d(Rep)q(ort)h(calls)g(these)g Fe(variables)p Fk(.)p eop %%Page: 16 16 bop 0 -40 a Fp(T-16)700 b Fj(4)45 b(CASE)15 b(EXPRESSIONS)i(AND)e(P)l(A)l (TTERN)h(MA)l(TCHING)0 105 y Fp(kinds)k(of)f(irrefutable)i(patterns,)e(t)o(w) o(o)g(of)g(whic)o(h)h(w)o(e)f(will)i(in)o(tro)q(duce)f(no)o(w)f(\(the)h (other)f(w)o(e)g(will)i(dela)o(y)f(un)o(til)0 162 y(Section)c(4.4\).)0 308 y Fc(As-patterns.)45 b Fp(Sometimes)16 b(it)h(is)f(con)o(v)o(enien)o(t)h (to)e(name)h(a)g(pattern)g(for)f(use)h(on)g(the)h(righ)o(t-hand)f(side.)24 b(F)l(or)0 365 y(example,)16 b(a)f(function)h(that)e(duplicates)j(the)e (\014rst)g(elemen)o(t)h(in)g(a)f(list)h(migh)o(t)f(b)q(e)h(written)f(as:)71 474 y Fi(f)23 b(\(x:xs\))381 b(=)24 b(x:x:xs)0 585 y Fp(\(Recall)17 b(that)d Fi(:)h Fp(asso)q(ciates)g(to)g(the)g(righ)o(t.\))k(Note)c(that)g Fi(x:xs)f Fp(app)q(ears)i(b)q(oth)f(as)g(a)g(pattern)g(on)g(the)g(left-hand)0 642 y(side,)k(and)f(an)f(expression)h(on)g(the)g(righ)o(t-hand)g(side.)28 b(T)l(o)17 b(impro)o(v)o(e)g(readabilit)o(y)l(,)j(w)o(e)d(migh)o(t)g(prefer)h (to)f(write)0 698 y Fi(x:xs)e Fp(just)g(once,)g(whic)o(h)h(w)o(e)f(can)g(ac)o (hiev)o(e)h(using)g(an)f Fo(as-p)n(attern)g Fp(as)g(follo)o(ws:)1353 682 y Fm(11)71 807 y Fi(f)23 b(s@\(x:xs\))309 b(=)24 b(x:s)0 919 y Fp(T)l(ec)o(hnically)17 b(sp)q(eaking,)d(as-patterns)g(alw)o(a)o(ys)f (result)i(in)g(a)f(successful)h(matc)o(h,)f(although)g(the)g(sub-pattern)g (\(in)0 975 y(this)i(case)f Fi(x:xs)o Fp(\))g(could,)h(of)f(course,)g(fail.)0 1122 y Fc(Wild-cards.)46 b Fp(Another)12 b(common)e(situation)i(is)g(matc)o (hing)f(against)g(a)g(v)m(alue)h(w)o(e)f(really)i(care)e(nothing)g(ab)q(out.) 0 1179 y(F)l(or)k(example,)g(the)h(functions)f Fi(head)g Fp(and)g Fi(tail)g Fp(de\014ned)i(in)f(Section)g(2.1)e(can)h(b)q(e)h(rewritten)f(as:) 71 1288 y Fi(head)23 b(\(_:xs\))309 b(=)24 b(x)71 1344 y(tail)f(\(x:_\))333 b(=)24 b(xs)0 1453 y Fp(in)14 b(whic)o(h)h(w)o(e)e(ha)o(v)o(e)g(\\adv)o (ertised")h(the)f(fact)g(that)g(w)o(e)g(don't)g(care)h(what)f(a)g(certain)h (part)f(of)g(the)h(input)g(is.)20 b(Eac)o(h)0 1510 y(wild-card)15 b(will)g(indep)q(enden)o(tly)h(matc)o(h)d(an)o(ything,)h(but)f(in)h(con)o (trast)f(to)f(a)h(formal)g(parameter,)g(eac)o(h)h(will)h(bind)0 1566 y(nothing;)g(for)g(this)h(reason)e(more)h(than)g(one)g(are)g(allo)o(w)o (ed)h(in)g(an)f(equation.)0 1713 y Fc(n)p Fi(+)p Fc(k-patterns.)45 b Fp(There)21 b(is)h(one)f(other)f(kind)i(of)e Fo(r)n(efutable)h Fp(pattern)f(in)i(Hask)o(ell,)h(called)f(an)f Fo(n)p Fi(+)o Fo(k-p)n(attern)p Fp(,)0 1769 y(whic)o(h)15 b(is)g(useful)h(when)f(writing)g (inductiv)o(e)h(de\014nitions)g(o)o(v)o(er)e(in)o(tegers.)20 b(F)l(or)13 b(example,)j(here's)e(a)g(de\014nition)i(of)0 1826 y(an)f(in\014x)h(op)q(erator)f Fi(^)g Fp(that)f(raises)i(its)f(\014rst)g (argumen)o(t)f(to)h(the)g(p)q(o)o(w)o(er)g(indicated)i(b)o(y)e(the)g(second:) 71 1935 y Fi(x)23 b(^)48 b(0)429 b(=)24 b(1)71 1991 y(x)f(^)h(\(n+1\))357 b(=)24 b(x*\(x^n\))0 2103 y Fp(\(A)15 b(more)g(e\016cien)o(t)h(de\014nition)h (of)d Fi(^)h Fp(is)h(giv)o(en)g(in)g(the)f(Standard)g(Prelude.\))71 2185 y(In)e(general,)h(the)f(pattern)g Fi(n+)p Fh(k)h Fp(matc)o(hes)f(an)o(y) g(in)o(teger)g(v)m(alue)i Fh(v)f Fn(\025)f Fh(k)q Fp(,)g(and)h(binds)g Fi(n)f Fp(to)g Fh(v)7 b Fn(\000)f Fh(k)q Fp(.)20 b(n)p Fi(+)p Fp(k-patterns)0 2241 y(ha)o(v)o(e)15 b(the)g(adv)m(an)o(tage)f(of)g(making)i (de\014nitions)g(suc)o(h)g(as)e(the)h(ab)q(o)o(v)o(e)g(lo)q(ok)g(v)o(ery)g (similar)h(to)e(the)h(corresp)q(onding)0 2298 y(mathematical)g(de\014nition:) 858 2342 y Fh(x)884 2326 y Fm(0)945 2342 y Fp(=)42 b(1)809 2399 y Fh(x)835 2382 y Fd(n)p Fm(+1)945 2399 y Fp(=)g Fh(x)10 b Fn(\003)g Fh(x)1117 2382 y Fd(n)0 2482 y Fp(\(See)15 b Fn(x)q Fp(3.14)f(for)g(a)h(formal)g(translation)g(of)g(n)p Fi(+)p Fp(k-patterns)g(in)o(to)g(a)g(more)g(primitiv)o(e)h(form.\))p 0 2525 780 2 v 37 2552 a Fl(11)69 2568 y Fk(Another)e(adv)n(an)o(tage)h(to)e (doing)i(this)g(is)f(that)f(a)h(naiv)o(e)h(implemen)o(tation)h(migh)o(t)f (completely)g(reconstruct)g Ff(x:xs)c Fk(rather)j(than)0 2614 y(re-use)f(the)g(v)n(alue)i(b)q(eing)f(matc)o(hed)g(against.)p eop %%Page: 17 17 bop 0 -40 a Fj(4.1)45 b(P)o(attern-Matc)o(hing)14 b(Seman)o(tics)1187 b Fp(T-17)0 105 y Fg(4.1)56 b(P)n(attern-Matc)n(hing)19 b(Seman)n(tics)0 220 y Fp(So)e(far)f(w)o(e)h(ha)o(v)o(e)f(discussed)j(ho)o(w)d(individual)k (patterns)c(are)h(matc)o(hed,)g(ho)o(w)f(some)h(are)f(refutable,)i(some)e (are)0 277 y(irrefutable,)i(etc.)26 b(But)17 b(what)g(driv)o(es)h(the)f(o)o (v)o(erall)g(pro)q(cess?)27 b(In)18 b(what)e(order)h(are)g(the)g(matc)o(hes)g (attempted?)0 333 y(What)e(if)g(none)h(succeed?)22 b(These)15 b(are)g(the)g(questions)h(addressed)g(in)g(this)g(section.)71 418 y(A)c(particular)g(matc)o(h)g(of)g(a)f(pattern)h(to)f(a)h(v)m(alue)i(can) e(actually)h(yield)g(one)g(of)e(three)h(results:)19 b Fo(failur)n(e)p Fp(;)13 b Fo(suc)n(c)n(ess)0 474 y Fp(\(returning)h(a)f(binding)i(for)d(eac)o (h)i(formal)f(parameter)f(in)i(the)g(pattern\);)f(or)f Fo(diver)n(genc)n(e)g Fp(\(i.e.)h(non)o(termination\).)0 531 y(The)i(matc)o(hing)h(pro)q(cess)f (itself)h(o)q(ccurs)g(\\top-do)o(wn,)e(left-to-righ)o(t.")20 b(F)l(ailure)c(of)f(a)g(pattern)g(an)o(ywhere)g(in)h(one)0 587 y(equation)c(results)g(in)g(failure)h(of)e(the)h(whole)g(equation,)h(and) e(the)h(next)g(equation)g(is)g(then)g(tried.)19 b(If)12 b(all)h(equations)0 644 y(fail,)j(the)f(v)m(alue)h(of)f(the)g(function)h(application)h(is)f Fn(?)p Fp(,)f(and)h(results)f(in)h(a)f(run-time)h(error.)71 728 y(F)l(or)i(example,)k(if)e Fi([1,2])e Fp(is)i(matc)o(hed)g(against)f Fi([0,bot])o Fp(,)h(then)g Fi(1)f Fp(fails)i(to)e(matc)o(h)g Fi(0)o Fp(,)i(so)e(the)g(result)h(is)0 785 y(a)f(failed)j(matc)o(h.)33 b(But)19 b(if)i Fi([1,2])e Fp(is)h(matc)o(hed)g(against)f Fi([bot,0])o Fp(,)i(then)f(matc)o(hing)f Fi(1)h Fp(against)f Fi(bot)h Fp(causes)0 841 y(div)o(ergence)c(\(i.e.)f Fn(?)p Fp(\).)71 926 y(The)d(only)h(other)f(t) o(wist)g(to)f(this)i(set)f(of)g(rules)h(is)g(that)e(top-lev)o(el)j(patterns)e (ma)o(y)f(also)i(ha)o(v)o(e)e(a)h(b)q(o)q(olean)i Fo(guar)n(d)p Fp(,)0 982 y(as)h(in)h(this)f(de\014nition)i(of)e(a)g(function)h(that)f (forms)f(an)h(abstract)f(v)o(ersion)i(of)f(a)f(n)o(um)o(b)q(er's)h(sign:)71 1091 y Fi(sign)23 b(x)h(|)47 b(x)24 b(>)48 b(0)190 b(=)72 b(1)238 1147 y(|)47 b(x)24 b(==)g(0)190 b(=)72 b(0)238 1204 y(|)47 b(x)24 b(<)48 b(0)190 b(=)48 b(-1)0 1313 y Fp(Note)16 b(that)f(a)h(sequence)i (of)e(guards)g(ma)o(y)f(b)q(e)i(pro)o(vided)g(for)f(the)g(same)g(pattern;)g (as)g(with)g(patterns,)g(they)g(are)0 1370 y(ev)m(aluated)g(top-do)o(wn,)f (and)g(the)g(\014rst)g(that)g(ev)m(aluates)h(to)e Fi(True)h Fp(results)g(in)h(a)f(successful)i(matc)o(h.)0 1527 y Fg(4.2)56 b(An)19 b(Example)0 1642 y Fp(The)i(pattern-matc)o(hing)f(rules)i(can)f(ha)o (v)o(e)f(subtle)h(e\013ects)g(on)f(the)h(meaning)g(of)f(functions.)37 b(F)l(or)20 b(example,)0 1698 y(consider)c(this)g(de\014nition)h(of)e Fi(take)o Fp(:)71 1799 y Fi(take)47 b(0)119 b(_)262 b(=)48 b([])71 1855 y(take)f(_)119 b([])238 b(=)48 b([])71 1912 y(take)23 b(\(n+1\))g(\(x:xs\))166 b(=)48 b(x)24 b(:)f(take)h(n)f(xs)0 2023 y Fp(and)15 b(this)h(sligh)o(tly)g(di\013eren)o(t)g(v)o(ersion)f(\(the)g (\014rst)g(2)g(equations)g(ha)o(v)o(e)g(b)q(een)i(rev)o(ersed\):)71 2135 y Fi(take1)47 b(_)119 b([])214 b(=)48 b([])71 2191 y(take1)f(0)119 b(_)238 b(=)48 b([])71 2248 y(take1)23 b(\(n+1\))g(\(x:xs\))142 b(=)48 b(x)24 b(:)f(take1)h(n)f(xs)0 2357 y Fp(No)o(w)15 b(note)g(the)g (follo)o(wing:)698 2414 y Fi(take)47 b(0)24 b(bot)111 b Fn(\))87 b Fi([])698 2470 y(take1)23 b(0)h(bot)111 b Fn(\))87 b(?)698 2557 y Fi(take)47 b(bot)24 b([])87 b Fn(\))g(?)698 2613 y Fi(take1)23 b(bot)h([])87 b Fn(\))g Fi([])p eop %%Page: 18 18 bop 0 -40 a Fp(T-18)700 b Fj(4)45 b(CASE)15 b(EXPRESSIONS)i(AND)e(P)l(A)l (TTERN)h(MA)l(TCHING)0 105 y Fp(W)l(e)h(see)h(that)f Fi(take)g Fp(is)h(\\more)e(de\014ned")j(with)f(resp)q(ect)f(to)g(its)h(second)g (argumen)o(t,)e(whereas)i Fi(take1)e Fp(is)i(more)0 162 y(de\014ned)h(with)f (resp)q(ect)g(to)f(its)h(\014rst.)27 b(It)18 b(is)g(di\016cult)h(to)f(sa)o(y) f(in)h(this)g(case)g(whic)o(h)h(de\014nition)g(is)f(b)q(etter.)28 b(Just)0 218 y(remem)o(b)q(er)16 b(that)f(in)i(certain)g(applications,)g(it)g (ma)o(y)e(mak)o(e)g(a)h(di\013erence.)24 b(\(The)15 b(Standard)h(Prelude)i (includes)0 274 y(a)d(de\014nition)i(corresp)q(onding)f(to)f Fi(take)o Fp(.\))0 423 y Fg(4.3)56 b(Case)19 b(Expressions)0 535 y Fp(P)o(attern)d(matc)o(hing)h(pro)o(vides)g(a)g(w)o(a)o(y)e(to)i (\\dispatc)o(h)g(con)o(trol")f(based)h(on)g(structural)g(prop)q(erties)g(of)g (a)f(v)m(alue.)0 591 y(Ho)o(w)o(ev)o(er,)21 b(in)h(man)o(y)e(circumstances)i (w)o(e)f(don't)g(wish)g(to)f(de\014ne)j(a)d Fo(function)h Fp(ev)o(ery)g(time) g(w)o(e)g(need)h(to)e(do)0 648 y(this,)c(but)g(so)g(far)g(w)o(e)f(ha)o(v)o(e) h(only)g(sho)o(wn)g(ho)o(w)g(to)f(do)h(pattern)g(matc)o(hing)g(in)h(function) f(de\014nitions.)25 b(Hask)o(ell's)0 704 y Fo(c)n(ase)16 b(expr)n(ession)e Fp(pro)o(vides)i(a)f(w)o(a)o(y)g(to)f(solv)o(e)i(this)g(problem.)21 b(Indeed,)c(the)f(meaning)g(of)f(pattern)g(matc)o(hing)g(in)0 761 y(function)k(de\014nitions)i(is)e(sp)q(eci\014ed)h(in)g(the)e(Rep)q(ort)h (in)h(terms)e(of)g(case)g(expressions,)i(whic)o(h)f(are)g(considered)0 817 y(more)c(primitiv)o(e.)21 b(In)16 b(particular,)f(a)g(function)h (de\014nition)h(of)e(the)g(form:)787 916 y Fi(f)h Fo(p)850 923 y Fb(11)917 916 y Fh(:)8 b(:)g(:)22 b Fo(p)1017 923 y Fb(1k)1074 916 y Fi(=)16 b Fo(e)1135 923 y Fb(1)787 973 y Fh(:)8 b(:)g(:)787 1029 y Fi(f)16 b Fo(p)850 1036 y Fb(n1)919 1029 y Fh(:)8 b(:)g(:)22 b Fo(p)1019 1036 y Fb(nk)1077 1029 y Fi(=)16 b Fo(e)1138 1036 y Fb(n)0 1129 y Fp(where)f(eac)o(h)h Fo(p)257 1136 y Fb(ij)301 1129 y Fp(is)g(a)e(pattern,)h(is)g(seman)o(tically)i(equiv)m(alen)o(t)g(to:) 288 1232 y Fi(f)23 b(x1)h(x2)g Fh(:)8 b(:)g(:)21 b Fi(xk)j(=)g(case)f(\(x1,) 31 b Fh(:)8 b(:)g(:)e Fi(,)23 b(xk\))h(of)c(\()p Fo(p)1240 1239 y Fb(11)1283 1232 y Fh(;)k(:)8 b(:)g(:)d(;)24 b Fo(p)1440 1239 y Fb(1k)1480 1232 y Fi(\))g(->)16 b Fo(e)1613 1239 y Fb(1)1193 1288 y Fh(:)8 b(:)g(:)1193 1344 y Fi(\()p Fo(p)1240 1351 y Fb(n1)1285 1344 y Fh(;)24 b(:)8 b(:)g(:)d(;)24 b Fo(p)1442 1351 y Fb(nk)1484 1344 y Fi(\))g(->)16 b Fo(e)1617 1351 y Fb(n)0 1446 y Fp(where)f(the)g Fi(xi)f Fp(are)h(new)g(iden)o(ti\014ers.)21 b(\(F)l(or)14 b(a)g(more)h(general)g(translation)g(that)f(includes)j(guards,) d(see)h Fn(x)p Fp(4.4.2.\))0 1503 y(F)l(or)g(example,)g(the)h(de\014nition)h (of)d Fi(take)h Fp(giv)o(en)h(earlier)g(is)f(equiv)m(alen)o(t)i(to:)71 1612 y Fi(take)23 b(m)h(ys)357 b(=)24 b(case)f(\(m,ys\))g(of)739 1668 y(\(0,_\))166 b(->)48 b([])739 1725 y(\(_,[]\))142 b(->)48 b([])739 1781 y(\(n+1,x:xs\))e(->)i(x)23 b(:)h(take)f(n)h(xs)71 1941 y Fp(A)13 b(p)q(oin)o(t)g(not)g(made)g(earlier)h(is)g(that,)f(for)f(t)o (yp)q(e)h(correctness,)g(the)h(t)o(yp)q(es)f(of)g(the)g(righ)o(t-hand)g (sides)h(of)f(a)g(case)0 1997 y(expression)h(or)e(set)h(of)f(equations)h (comprising)h(a)e(function)i(de\014nition)h(m)o(ust)d(all)i(b)q(e)f(the)g (same;)g(more)f(precisely)l(,)0 2054 y(they)j(m)o(ust)g(all)h(share)f(a)g (common)g(principal)i(t)o(yp)q(e.)71 2136 y(The)j(pattern-matc)o(hing)g (rules)g(for)g(case)g(expressions)h(are)e(the)h(same)g(as)g(w)o(e)g(ha)o(v)o (e)f(giv)o(en)i(for)e(function)0 2192 y(de\014nitions,)h(so)d(there)h(is)g (really)h(nothing)f(new)g(to)f(learn)h(here,)h(other)e(than)h(to)f(note)h (the)f(con)o(v)o(enience)j(that)0 2248 y(case)d(expressions)g(o\013er.)24 b(Indeed,)19 b(there's)d(one)h(use)g(of)g(a)f(case)h(expression)h(that)e(is)h (so)f(common)h(that)f(it)h(has)0 2305 y(sp)q(ecial)k(syn)o(tax:)27 b(the)19 b Fo(c)n(onditional)g(expr)n(ession)p Fp(.)31 b(In)20 b(Hask)o(ell,)g(conditional)h(expressions)f(ha)o(v)o(e)f(the)g(familiar)0 2361 y(form:)756 2419 y Fi(if)c Fh(e)840 2426 y Fm(1)875 2419 y Fi(then)g Fh(e)1007 2426 y Fm(2)1042 2419 y Fi(else)g Fh(e)1174 2426 y Fm(3)0 2503 y Fp(whic)o(h)h(is)g(really)g(short-hand)f(for:)724 2557 y Fi(case)f Fh(e)855 2564 y Fm(1)890 2557 y Fi(of)41 b(True)48 b(->)15 b Fh(e)1207 2564 y Fm(2)979 2613 y Fi(False)24 b(->)15 b Fh(e)1207 2620 y Fm(3)p eop %%Page: 19 19 bop 0 -40 a Fj(4.4)45 b(Lazy)15 b(P)o(atterns)1473 b Fp(T-19)0 105 y(F)l(rom)15 b(this)g(expansion)i(it)e(should)i(b)q(e)f(clear)g(that)e Fh(e)900 112 y Fm(1)936 105 y Fp(m)o(ust)h(ha)o(v)o(e)g(t)o(yp)q(e)g Fi(Bool)o Fp(,)g(and)h Fh(e)1489 112 y Fm(2)1524 105 y Fp(and)g Fh(e)1634 112 y Fm(3)1669 105 y Fp(m)o(ust)f(ha)o(v)o(e)g(the)0 162 y(same)e(\(but)g(otherwise)h(arbitrary\))e(t)o(yp)q(e.)19 b(In)14 b(other)f(w)o(ords,)f Fi(if)p 1104 162 14 2 v 16 w(then)p 1216 162 V 16 w(else)p 1327 162 V 29 w Fp(when)i(view)o(ed)g(as)f(a)g (function)h(has)0 218 y(t)o(yp)q(e)h Fi(Bool->a->a->a)n Fp(.)0 365 y Fg(4.4)56 b(Lazy)18 b(P)n(atterns)0 476 y Fp(There)e(is)f(one)h(other)f (kind)h(of)f(pattern)g(allo)o(w)o(ed)h(in)g(Hask)o(ell.)21 b(It)16 b(is)g(called)h(a)e Fo(lazy)h(p)n(attern)p Fp(,)e(and)i(has)f(the)h (form)0 533 y Fi(~)p Fh(pat)p Fp(.)28 b(Lazy)18 b(patterns)f(are)h Fo(irr)n(efutable)p Fp(:)25 b(matc)o(hing)18 b(a)f(v)m(alue)j Fh(v)f Fp(against)e Fi(~)p Fh(pat)h Fp(alw)o(a)o(ys)g(succeeds,)h(regardless) 0 589 y(of)c Fh(pat)p Fp(.)20 b(Op)q(erationally)d(sp)q(eaking,)f(if)g(an)f (iden)o(ti\014er)i(in)f Fh(pat)f Fp(is)h(later)f(\\used")h(on)f(the)g(righ)o (t-hand-side,)i(it)e(will)0 646 y(b)q(e)g(b)q(ound)h(to)e(that)g(p)q(ortion)h (of)g(the)f(v)m(alue)i(that)f(w)o(ould)g(result)g(if)g Fh(v)h Fp(w)o(ere)f(to)f(successfully)j(matc)o(h)d Fh(pat)p Fp(,)h(and)g Fn(?)0 702 y Fp(otherwise.)71 784 y(Lazy)22 b(patterns)g(are)g(useful)i(in)f (con)o(texts)f(where)h(in\014nite)h(lists)g(are)e(b)q(eing)h(de\014ned)h (recursiv)o(ely)l(.)44 b(F)l(or)0 840 y(example,)16 b(in\014nite)h(lists)e (are)g(an)g(excellen)o(t)i(v)o(ehicle)g(for)e(writing)g Fo(simulation)g Fp(programs,)f(and)h(in)h(this)g(con)o(text)0 897 y(the)h(in\014nite)j(lists) e(are)f(often)g(called)i Fo(str)n(e)n(ams)p Fp(.)25 b(Consider)18 b(the)g(simple)g(case)g(of)f(sim)o(ulating)h(the)g(in)o(teractions)0 953 y(b)q(et)o(w)o(een)g(a)f(serv)o(er)g(pro)q(cess)h Fi(server)f Fp(and)g(a)h(clien)o(t)g(pro)q(cess)g Fi(client)o Fp(,)g(where)g Fi(client)e Fp(sends)i(a)g(sequence)g(of)0 1010 y Fo(r)n(e)n(quests)c Fp(to)h Fi(server)o Fp(,)g(and)g Fi(server)g Fp(replies)i(to)d(eac)o(h)i (request)f(with)h(some)f(kind)h(of)f Fo(r)n(esp)n(onse)p Fp(.)k(This)d (situation)0 1066 y(is)i(sho)o(wn)e(pictorially)j(in)f(Figure)f(1b,)g(just)g (as)f(w)o(e)h(did)h(with)g(the)f(Fib)q(onacci)h(example.)26 b(\(Note)17 b(that)f Fi(client)0 1122 y Fp(also)g(tak)o(es)f(an)h(initial)i (message)d(as)h(argumen)o(t.\))21 b(Using)c(streams)e(to)g(sim)o(ulate)h(the) h(message)e(sequences,)i(the)0 1179 y(Hask)o(ell)f(co)q(de)g(corresp)q (onding)g(to)f(this)g(diagram)g(is:)71 1288 y Fi(reqs)500 b(=)24 b(client)f(init)g(resps)71 1344 y(resps)476 b(=)24 b(server)f(reqs)0 1453 y Fp(These)16 b(recursiv)o(e)f(equations)h(are)f(a)g(direct)h(lexical)h (transliteration)e(of)g(the)g(diagram.)71 1535 y(Let)g(us)g(further)g(assume) g(that)g(the)g(structure)g(of)g(the)g(serv)o(er)g(and)g(clien)o(t)i(lo)q(ok)e (something)h(lik)o(e)g(this:)71 1644 y Fi(client)23 b(init)g(\(resp:resps\))f (=)i(init)f(:)h(client)f(\(next)g(resp\))g(resps)71 1700 y(server)142 b(\(req:reqs\))70 b(=)24 b(process)f(req)g(:)h(server)f(reqs)0 1809 y Fp(where)18 b(w)o(e)g(assume)g(that)g Fi(next)f Fp(is)i(a)f(function)h (that,)f(giv)o(en)g(a)g(resp)q(onse)h(from)e(the)i(serv)o(er,)f(determines)h (the)0 1866 y(next)i(request,)g(and)g Fi(process)f Fp(is)h(a)g(function)g (that)f(pro)q(cesses)h(a)f(request)h(from)f(the)h(clien)o(t,)i(returning)e (an)0 1922 y(appropriate)15 b(resp)q(onse.)71 2004 y(Unfortunately)l(,)d (this)f(program)f(has)h(a)g(serious)h(problem:)18 b(it)12 b(will)h(not)e(pro) q(duce)h(an)o(y)e(output!)19 b(The)11 b(problem)0 2060 y(is)h(that)e Fi(client)o Fp(,)i(as)f(used)g(in)h(the)g(recursiv)o(e)g(setting)f(of)g Fi(reqs)f Fp(and)i Fi(resps)o Fp(,)f(attempts)g(a)f(matc)o(h)h(on)g(the)g (resp)q(onse)0 2117 y(list)18 b(b)q(efore)g(it)g(has)g(submitted)g(its)g (\014rst)f(request!)27 b(In)19 b(other)e(w)o(ords,)g(the)h(pattern)f(matc)o (hing)h(is)g(b)q(eing)h(done)0 2173 y(\\to)q(o)14 b(early)l(.")20 b(One)c(w)o(a)o(y)f(to)f(\014x)h(this)h(is)g(to)e(rede\014ne)j Fi(client)d Fp(as)h(follo)o(ws:)71 2282 y Fi(client)23 b(init)g(resps)214 b(=)24 b(init)f(:)h(client)f(\(next)g(\(head)g(resps\)\))g(\(tail)g(resps\))0 2391 y Fp(Although)15 b(w)o(ork)m(able,)f(this)g(solution)h(do)q(es)g(not)e (read)h(as)g(w)o(ell)h(as)f(that)f(giv)o(en)i(earlier.)20 b(A)14 b(b)q(etter)g(solution)h(is)g(to)0 2448 y(use)h(a)e(lazy)i(pattern:)71 2557 y Fi(client)23 b(init)g(~\(resp:resps\))f(=)i(init)f(:)h(client)f (\(next)g(resp\))g(resps)p eop %%Page: 20 20 bop 0 -40 a Fp(T-20)700 b Fj(4)45 b(CASE)15 b(EXPRESSIONS)i(AND)e(P)l(A)l (TTERN)h(MA)l(TCHING)0 105 y Fp(Because)22 b(lazy)h(patterns)e(are)g (irrefutable,)j(the)e(matc)o(h)f(will)j(immediately)f(succeed,)h(allo)o(wing) f(the)f(initial)0 162 y(request)17 b(to)f(b)q(e)i(\\submitted,")g(in)f(turn)g (allo)o(wing)h(the)f(\014rst)g(resp)q(onse)h(to)e(b)q(e)i(generated;)f(the)h (engine)g(is)f(no)o(w)0 218 y(\\primed,")e(and)h(the)f(recursion)h(tak)o(es)e (care)h(of)g(the)g(rest.)71 306 y(As)g(an)g(example)h(of)f(this)g(program)f (in)i(action,)f(if)h(w)o(e)f(de\014ne:)71 415 y Fi(init)476 b(=)24 b(0)71 472 y(next)f(resp)357 b(=)24 b(resp)71 528 y(process)e(req)310 b(=)24 b(req+1)0 637 y Fp(then)16 b(w)o(e)e(see)i(that:)485 704 y Fi(take)24 b(10)f(reqs)73 b Fn(\))h Fi([0,1,2,3,4,5,6,7,8,9])71 830 y Fp(The)13 b(serv)o(er/clien)o(t)h(example)g(w)o(as)e(delib)q(erately)k (c)o(hosen)d(to)f(demonstrate)h(a)g(t)o(ypical)h(use)f(of)g(lazy)g(patterns)0 887 y(and)19 b(streams,)f(and)g(also)h(to)f(aid)h(the)f(user)h(in)o(terested) g(in)g(using)h(Hask)o(ell's)f Fo(str)n(e)n(am-b)n(ase)n(d)f(I/O)p Fp(,)g(in)h(whic)o(h)g(a)0 943 y(Hask)o(ell)14 b(program)f(is)g(essen)o (tially)i(the)f(clien)o(t,)g(with)g(the)g(op)q(erating)f(system)g(acting)h (as)f(serv)o(er)g(\()p Fn(x)p Fp(7\).)18 b(Although)0 1000 y(in)d(this)g(tutorial)f(w)o(e)g(will)i(only)f(discuss)g Fo(c)n (ontinuation-b)n(ase)n(d)g(I/O)f Fp(\(see)g(Section)h(8\),)e(the)i (stream-based)f(alter-)0 1056 y(nativ)o(e)j(is)h(an)f(excellen)o(t)i(example) f(of)e(the)h(use)h(of)e(lazy)i(patterns)f(and)g(streams.)24 b(Indeed,)19 b(the)e(stream-based)0 1113 y(I/O)f(example)g(in)g(the)f(Rep)q (ort)h(uses)f(lazy)h(patterns.)71 1201 y(As)11 b(another)g(example)i(of)e (the)h(use)g(of)f(lazy)h(patterns,)g(consider)h(the)e(de\014nition)j(of)d (Fib)q(onacci)i(giv)o(en)f(earlier:)71 1310 y Fi(fib)309 b(=)24 b(1)g(:)g(1)f(:)h([)g(a+b)f(|)h(\(a,b\))f(<-)h(zip)f(fib)h(\(tail)f(fib\))g (])0 1419 y Fp(W)l(e)15 b(migh)o(t)g(try)g(rewriting)h(this)f(using)h(an)f (as-pattern:)71 1528 y Fi(fib@\(1:tfib\))70 b(=)23 b(1)h(:)g(1)f(:)h([)g(a+b) f(|)h(\(a,b\))f(<-)h(zip)f(fib)h(tfib)f(])0 1639 y Fp(This)16 b(v)o(ersion)g(of)f Fi(fib)g Fp(has)h(the)f(\(small)h(adv)m(an)o(tage\))f(of) g(not)g(using)i Fi(tail)e Fp(on)g(the)h(righ)o(t-hand)g(side,)g(since)h(it)e (is)0 1696 y(a)o(v)m(ailable)i(in)f(\\destructured")f(form)f(on)i(the)f (left-hand)h(side)g(as)f Fi(tfib)o Fp(.)71 1784 y([This)f(kind)h(of)f (equation)g(is)h(called)h(a)e Fo(p)n(attern)h(binding)e Fp(b)q(ecause)i(it)g (is)f(a)g(top-lev)o(el)h(equation)g(in)g(whic)o(h)g(the)0 1840 y(en)o(tire)k(left-hand)g(side)g(is)g(a)f(pattern;)h(i.e.)f(b)q(oth)g Fi(fib)g Fp(and)h Fi(tfib)e Fp(b)q(ecome)i(b)q(ound)g(within)h(the)e(scop)q (e)h(of)f(the)0 1897 y(declaration.])71 1985 y(No)o(w,)12 b(using)h(the)g (same)g(reasoning)g(w)o(e)f(did)i(earlier,)g(w)o(e)f(should)h(b)q(e)f(led)h (to)e(b)q(eliev)o(e)j(that)d(this)i(program)d(will)0 2041 y(not)j(generate)h (an)o(y)f(output.)19 b(Curiously)l(,)d(ho)o(w)o(ev)o(er,)d(it)i Fo(do)n(es)p Fp(,)f(and)h(the)f(reason)h(is)g(simple:)21 b(in)15 b(Hask)o(ell,)g(pattern)0 2098 y(bindings)i(are)e(assumed)g(to)f(ha)o(v)o(e)h (an)f(implicit)k Fi(~)d Fp(in)h(fron)o(t)e(of)g(them,)h(re\015ecting)h(the)f (most)f(common)g(b)q(eha)o(vior)0 2154 y(exp)q(ected)h(of)f(pattern)g (bindings,)i(and)e(a)o(v)o(oiding)h(some)f(anomalous)g(situations)g(whic)o(h) h(are)f(b)q(ey)o(ond)h(the)f(scop)q(e)0 2211 y(of)f(this)h(tutorial.)19 b(Th)o(us)14 b(w)o(e)f(see)h(that)e(lazy)i(patterns)f(pla)o(y)h(an)g(imp)q (ortan)o(t)f(role)g(in)i(Hask)o(ell,)f(if)g(only)g(implicitly)l(.)0 2380 y Fg(4.5)56 b(Lexical)16 b(Scoping)j(and)g(Nested)f(F)-5 b(orms)0 2501 y Fp(It)14 b(is)h(often)f(desirable)i(to)e(create)g(a)g(nested) h(scop)q(e)g(within)g(an)f(expression,)h(for)f(the)g(purp)q(ose)h(of)f (creating)h(lo)q(cal)0 2557 y(bindings)i(not)f(seen)g(elsewhere|i.e.)23 b(some)15 b(kind)h(of)g(\\blo)q(c)o(k-structuring")g(form.)k(In)c(Hask)o(ell) g(there)g(are)f(t)o(w)o(o)0 2614 y(w)o(a)o(ys)f(to)h(ac)o(hiev)o(e)g(this:)p eop %%Page: 21 21 bop 0 -40 a Fj(4.6)45 b(La)o(y)o(out)1614 b Fp(T-21)0 105 y Fc(Let)23 b(Expressions.)44 b Fp(Hask)o(ell's)19 b Fo(let)h(expr)n(essions)d Fp(are)i(useful)h(whenev)o(er)g(a)e(nested)i(set)f(of)f(bindings)j(is)f(re-)0 162 y(quired.)h(As)15 b(a)g(simple)i(example,)e(consider:)71 271 y Fi(let)23 b(y)71 b(=)24 b(a*b)166 327 y(f)g(x)f(=)h(\(x+y\)/y)71 383 y(in)f(f)h(c)g(+)f(f)h(d)0 493 y Fp(The)19 b(set)g(of)f(bindings)j (created)e(b)o(y)g(a)g Fi(let)f Fp(expression)i(is)f Fo(mutual)r(ly)i(r)n(e)n (cursive)p Fp(,)e(and)g(pattern)f(bindings)j(are)0 549 y(treated)c(as)g(lazy) i(patterns)e(\(i.e.)27 b(they)18 b(carry)f(an)h(implicit)i Fi(~)p Fp(\).)27 b(The)18 b(only)g(kind)h(of)e(declarations)h(p)q(ermitted)0 605 y(are)d Fo(typ)n(e)h(signatur)n(es)p Fp(,)e Fo(function)i(bindings)p Fp(,)d(and)j Fo(p)n(attern)g(bindings)p Fp(.)0 780 y Fc(Where)j(Clauses.)45 b Fp(Sometimes)18 b(it)f(is)h(con)o(v)o(enien)o(t)g(to)e(scop)q(e)i(bindings) h(o)o(v)o(er)d(sev)o(eral)i(guarded)f(equations,)0 836 y(whic)o(h)f(requires) g(a)f Fo(wher)n(e)h(clause)p Fp(:)71 945 y Fi(f)23 b(x)h(y)48 b(|)f(y>z)262 b(=)48 b(...)238 1001 y(|)f(y==z)238 b(=)48 b(...)238 1058 y(|)f(y[a]->Bool)n Fp(.)f(But)14 b(this)f(w)o(ould)h(imply)h(that)d Fi(==)0 1202 y Fp(has)i(t)o(yp)q(e)g Fi(a->a->Bool)n Fp(,)g(ev)o(en)g(though)g(w)o(e)g (just)f(said)i(that)e(w)o(e)h(don't)f(exp)q(ect)i Fi(==)e Fp(to)g(b)q(e)i (de\014ned)g(for)e(all)i(t)o(yp)q(es.)71 1279 y(F)l(urthermore,)20 b(as)g(w)o(e)f(ha)o(v)o(e)h(noted)g(earlier,)i(ev)o(en)e(if)h Fi(==)f Fo(wer)n(e)g Fp(de\014ned)h(on)f(all)h(t)o(yp)q(es,)g(comparing)f(t)o (w)o(o)0 1335 y(lists)e(for)e(equalit)o(y)i(is)g Fo(very)g(di\013er)n(ent)e Fp(from)h(comparing)g(t)o(w)o(o)f(in)o(tegers.)25 b(In)18 b(this)g(sense,)f (w)o(e)g(exp)q(ect)h Fi(==)f Fp(to)f(b)q(e)0 1392 y Fo(overlo)n(ade)n(d)f Fp(to)g(carry)f(on)i(these)f(v)m(arious)h(tasks.)71 1468 y Fo(T)m(yp)n(e)h(classes)f Fp(con)o(v)o(enien)o(tly)j(solv)o(e)f(b)q(oth)g(of) f(these)h(problems)g(b)o(y)g(allo)o(wing)h(us)f(to)f(declare)h(whic)o(h)h(t)o (yp)q(es)0 1525 y(are)13 b Fo(instanc)n(es)e Fp(of)i(whic)o(h)i(class,)e(and) h(to)f(pro)o(vide)g(de\014nitions)j(of)c(the)i(o)o(v)o(erloaded)f Fo(op)n(er)n(ations)g Fp(asso)q(ciated)h(with)0 1581 y(a)h(class.)20 b(F)l(or)15 b(example,)g(let's)h(de\014ne)g(a)f(t)o(yp)q(e)g(class)h(con)o (taining)g(an)f(equalit)o(y)h(op)q(erator:)71 1690 y Fi(class)23 b(Eq)g(a)h(where)118 1747 y(\(==\))429 b(::)24 b(a)g(->)f(a)h(->)g(Bool)0 1856 y Fp(Here)18 b Fi(Eq)g Fp(is)g(the)g(name)g(of)f(the)h(class)h(b)q(eing) g(de\014ned,)g(and)f Fi(==)g Fp(is)g(the)g(single)h(op)q(eration)f(in)h(the)f (class.)28 b(This)0 1912 y(declaration)13 b(ma)o(y)f(b)q(e)h(read)g(\\a)f(t)o (yp)q(e)g Fi(a)h Fp(is)g(an)f(instance)i(of)e(the)h(class)f Fi(Eq)h Fp(if)g(there)f(is)h(an)g(\(o)o(v)o(erloaded\))f(op)q(eration)0 1969 y Fi(==)p Fp(,)i(of)g(the)h(appropriate)g(t)o(yp)q(e,)f(de\014ned)i(on)f (it.")20 b(\(Note)14 b(that)g Fi(==)g Fp(is)h(only)h(de\014ned)g(on)e(pairs)h (of)g(ob)s(jects)f(of)g(the)0 2025 y(same)h(t)o(yp)q(e.\))71 2102 y(The)i(constrain)o(t)f(that)h(a)f(t)o(yp)q(e)i Fi(a)e Fp(m)o(ust)h(b)q(e)h(an)f(instance)g(of)g(the)g(class)g Fi(Eq)g Fp(is)h(written)f Fi(Eq)23 b(a)p Fp(.)j(Th)o(us)17 b Fi(Eq)23 b(a)0 2158 y Fp(is)c(not)g(a)g(t)o(yp)q(e)g(expression,)h(but)f(rather)f(it)i (expresses)f(a)g(constrain)o(t)f(on)h(a)g(t)o(yp)q(e,)g(and)g(is)h(called)g (a)f Fo(c)n(ontext)p Fp(.)0 2215 y(Con)o(texts)14 b(are)h(app)q(ended)i(to)e (the)g(fron)o(t)f(of)h(t)o(yp)q(e)h(expressions.)21 b(F)l(or)14 b(example,)i(the)f(e\013ect)g(of)g(the)h(ab)q(o)o(v)o(e)f(class)0 2271 y(declaration)h(is)g(to)e(assign)i(the)f(follo)o(wing)h(t)o(yp)q(e)f(to) g Fi(==)o Fp(:)71 2380 y Fi(\(==\))476 b(::)24 b(\(Eq)f(a\))h(=>)g(a)f(->)h (a)g(->)f(Bool)p 0 2480 780 2 v 37 2506 a Fl(13)69 2522 y Fk(The)15 b(kind)h(of)e(equalit)o(y)j(w)o(e)d(are)h(referring)h(to)f(here)g(is)g(\\v)n (alue)h(equalit)o(y)m(,")h(and)e(opp)q(osed)i(to)d(the)h(\\p)q(oin)o(ter)h (equalit)o(y")h(found,)0 2568 y(for)f(example,)h(in)g(Lisp's)g Ff(eq)o Fk(.)26 b(P)o(oin)o(ter)17 b(equalit)o(y)h(is)e(not)h(referen)o (tially)h(transparen)o(t,)g(and)e(th)o(us)h(do)q(es)f(not)g(sit)h(w)o(ell)g (in)f(a)g(purely)0 2614 y(functional)f(language.)p eop %%Page: 24 24 bop 0 -40 a Fp(T-24)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")0 105 y Fp(This)e(should)g(b)q(e)g(read,)f(\\F)l(or)f(ev)o(ery) i(t)o(yp)q(e)f Fi(a)g Fp(that)f(is)i(an)f(instance)h(of)f(the)g(class)h Fi(Eq)o Fp(,)g Fi(==)f Fp(has)g(t)o(yp)q(e)g Fi(a->a->Bool)o Fp(.")0 162 y(This)i(is)g(the)g(t)o(yp)q(e)f(that)g(w)o(ould)h(b)q(e)g(used)h (for)e Fi(==)g Fp(in)h(the)g Fi(elem)f Fp(example,)h(and)g(indeed)h(the)f (constrain)o(t)f(imp)q(osed)0 218 y(b)o(y)i(the)g(con)o(text)g(propagates)f (to)h(the)g(principal)j(t)o(yp)q(e)d(for)f Fi(elem)p Fp(:)71 327 y Fi(elem)476 b(::)24 b(\(Eq)f(a\))h(=>)g(a)f(->)h([a])f(->)h(Bool)0 436 y Fp(This)11 b(should)g(b)q(e)g(read,)f(\\F)l(or)g(ev)o(ery)g(t)o(yp)q(e) g Fi(a)g Fp(that)f(is)i(an)f(instance)h(of)f(the)g(class)g Fi(Eq)p Fp(,)h Fi(elem)e Fp(has)i(t)o(yp)q(e)f Fi(a->[a]->Bool)n Fp(.")0 493 y(This)18 b(is)f(just)g(what)f(w)o(e)h(w)o(an)o(t|it)g(expresses) g(the)g(fact)g(that)f Fi(elem)g Fp(is)i(not)e(de\014ned)j(on)e Fo(al)r(l)f Fp(t)o(yp)q(es,)i(just)e(those)0 549 y(for)f(whic)o(h)h(w)o(e)f (kno)o(w)f(ho)o(w)h(to)f(compare)h(its)h(elemen)o(ts)g(for)e(equalit)o(y)l(.) 71 625 y(So)f(far)h(so)f(go)q(o)q(d.)19 b(But)14 b(ho)o(w)g(do)f(w)o(e)h(sp)q (ecify)h(whic)o(h)g(t)o(yp)q(es)f(are)f(instances)i(of)e(the)h(class)g Fi(Eq)p Fp(,)g(and)g(the)g(actual)0 682 y(b)q(eha)o(vior)i(of)f Fi(==)f Fp(on)i(eac)o(h)f(of)g(those)f(t)o(yp)q(es?)21 b(This)16 b(is)g(done)f(with)h(an)f Fo(instanc)n(e)g(de)n(clar)n(ation)p Fp(.)k(F)l(or)c(example:)71 791 y Fi(instance)22 b(Eq)i(Int)f(where)118 847 y(x)h(==)g(y)381 b(=)48 b(intEq)23 b(x)h(y)0 956 y Fp(The)15 b(de\014nition)h(of)e Fi(==)g Fp(is)i(called)g(a)e Fo(metho)n(d)p Fp(.)20 b Fi(intEq)14 b Fp(happ)q(ens)h(to)f(b)q(e)i(the)e(primitiv)o(e)i (function)f(that)f(compares)0 1013 y(in)o(tegers)i(for)g(equalit)o(y)l(,)h (but)f(in)h(general)g(an)o(y)f(v)m(alid)h(expression)g(is)g(allo)o(w)o(ed)g (on)f(the)g(righ)o(t-hand)h(side,)f(just)g(as)0 1069 y(for)e(an)o(y)f(other)h (function)h(de\014nition.)21 b(The)15 b(o)o(v)o(erall)f(declaration)h(is)g (essen)o(tially)g(sa)o(ying:)k(\\The)c(t)o(yp)q(e)f Fi(Int)f Fp(is)i(an)0 1126 y(instance)j(of)f(the)h(class)g Fi(Eq)p Fp(,)f(and)h(here)g (is)g(the)g(de\014nition)h(of)e(the)h(metho)q(d)g(corresp)q(onding)g(to)f (the)h(op)q(eration)0 1182 y Fi(==)p Fp(.")31 b(Giv)o(en)19 b(this)h(declaration,)g(w)o(e)f(can)g(no)o(w)f(compare)h(\014xed)h(precision) h(in)o(tegers)e(for)f(equalit)o(y)i(using)g Fi(==)o Fp(.)0 1239 y(Similarly:)71 1347 y Fi(instance)i(Eq)i(Float)f(where)118 1404 y(x)h(==)g(y)381 b(=)48 b(floatEq)23 b(x)h(y)0 1513 y Fp(allo)o(ws)15 b(us)h(to)e(compare)h(\015oating)g(p)q(oin)o(t)h(n)o(um)o(b)q (ers)f(using)h Fi(==)p Fp(.)71 1589 y(Recursiv)o(e)g(t)o(yp)q(es)f(suc)o(h)h (as)f Fi(Tree)f Fp(de\014ned)j(earlier)f(can)f(also)g(b)q(e)h(handled:)71 1698 y Fi(instance)22 b(\(Eq)i(a\))f(=>)h(Eq)g(\(Tree)f(a\))g(where)118 1755 y(Leaf)h(a)214 b(==)24 b(Leaf)f(b)239 b(=)47 b(a)24 b(==)g(b)118 1811 y(\(Branch)f(l1)h(r1\))f(==)h(\(Branch)f(l2)g(r2\))48 b(=)f(\(l1==l2\))23 b(&&)h(\(r1==r2\))118 1868 y(_)334 b(==)24 b(_)358 b(=)47 b(False)0 1979 y Fp(Note)16 b(the)g(con)o(text)40 b Fi(Eq)23 b(a)40 b Fp(in)17 b(the)g(\014rst)e(line|this)k(is)e(necessary)g (b)q(ecause)g(the)f(elemen)o(ts)h(in)g(the)f(lea)o(v)o(es)h(\(of)0 2036 y(t)o(yp)q(e)e Fi(a)p Fp(\))f(are)h(compared)g(for)f(equalit)o(y)i(in)g (line)h(2.)i(The)c(additional)i(constrain)o(t)d(is)i(essen)o(tially)g(sa)o (ying)f(that)f(w)o(e)0 2092 y(can)k(compare)f(trees)g(of)g Fi(a)p Fp('s)g(for)g(equalit)o(y)i(as)e(long)h(as)f(w)o(e)g(kno)o(w)g(ho)o(w) g(to)g(compare)g Fi(a)p Fp('s)g(for)g(equalit)o(y)l(.)28 b(If)18 b(the)0 2149 y(con)o(text)d(w)o(ere)g(omitted,)f(a)h(static)g(t)o(yp)q(e)h (error)e(w)o(ould)i(result.)71 2225 y(The)h(Hask)o(ell)h(Rep)q(ort,)f(esp)q (ecially)j(the)d(Standard)g(Prelude,)i(con)o(tains)e(a)g(w)o(ealth)g(of)f (useful)j(examples)e(of)0 2281 y(t)o(yp)q(e)e(classes.)21 b(Indeed,)16 b(a)f(class)g Fi(Eq)g Fp(is)h(de\014ned)h(that)d(is)i(sligh)o(tly)g(larger)f (than)g(the)h(one)f(de\014ned)h(earlier:)71 2392 y Fi(class)47 b(Eq)23 b(a)48 b(where)118 2448 y(\(==\),)23 b(\(/=\))286 b(::)24 b(a)g(->)f(a)h(->)g(Bool)118 2504 y(x)g(/=)g(y)381 b(=)48 b(not)23 b(\(x)h(==)g(y\))0 2614 y Fp(This)15 b(is)g(an)g(example)g(of)g(a)f(class)h (with)g Fo(two)g Fp(op)q(erations,)g(one)f(for)g(equalit)o(y)l(,)i(the)e (other)h(for)f(inequalit)o(y)l(.)21 b(It)15 b(also)p eop %%Page: 25 25 bop 1857 -40 a Fp(T-25)0 105 y(demonstrates)14 b(the)h(use)g(of)f(a)h Fo(default)h(metho)n(d)p Fp(,)f(in)h(this)f(case)g(for)f(the)h(inequalit)o(y) i(op)q(eration)e Fi(/=)o Fp(.)20 b(If)15 b(a)g(metho)q(d)0 162 y(for)k(a)f(particular)i(op)q(eration)g(is)f(omitted)h(in)g(an)f (instance)h(declaration,)h(then)e(the)g(default)h(one)g(de\014ned)g(in)0 218 y(the)e(class)g(declaration,)h(if)g(it)f(exists,)g(is)h(used)f(instead.) 29 b(F)l(or)17 b(example,)i(the)f(three)g(instances)h(of)e Fi(Eq)h Fp(de\014ned)0 274 y(earlier)d(will)g(w)o(ork)e(p)q(erfectly)i(w)o (ell)g(with)g(the)f(ab)q(o)o(v)o(e)f(class)h(declaration,)h(yielding)h(just)e (the)g(righ)o(t)g(de\014nition)h(of)0 331 y(inequalit)o(y)i(that)d(w)o(e)h(w) o(an)o(t:)k(the)c(logical)i(negation)e(of)g(equalit)o(y)l(.)71 408 y(Hask)o(ell)j(also)f(supp)q(orts)g(a)g(notion)g(of)g Fo(class)g (inclusion)p Fp(.)24 b(F)l(or)17 b(example,)h(w)o(e)f(ma)o(y)f(wish)i(to)e (de\014ne)j(a)e(class)0 464 y Fi(Ord)f Fp(whic)o(h)g Fo(inherits)g Fp(all)h(of)e(the)h(op)q(erations)g(in)h(Eq,)f(but)g(in)h(addition)g(has)f(a) f(set)h(of)g(comparison)g(op)q(erations)0 520 y(and)f(minim)o(um)i(and)e (maxim)o(um)g(functions:)71 621 y Fi(class)47 b(\(Eq)23 b(a\))h(=>)f(Ord)h(a) 47 b(where)118 677 y(\(<\),)24 b(\(<=\),)f(\(>=\),)g(\(>\))47 b(::)24 b(a)g(->)f(a)h(->)g(Bool)118 733 y(max,)g(min)333 b(::)24 b(a)g(->)f(a)h(->)g(a)0 845 y Fp(Note)16 b(the)g(con)o(text)f(in)i(the)f Fi(class)g Fp(declaration.)23 b(W)l(e)16 b(sa)o(y)f(that)h Fi(Eq)f Fp(is)i(a)f Fo(sup)n(er)n(class)e Fp(of)i Fi(Ord)f Fp(\(con)o(v)o(ersely)l(,)h Fi(Ord)0 902 y Fp(is)h(a)f Fo(sub)n(class)f Fp(of)g Fi(Eq)p Fp(\),)h(and)h(an)o(y)f(instance)h(of)f Fi(Ord)f Fp(m)o(ust)h(also)g(b)q(e)h(an)g(instance)g(of)f Fi(Eq)o Fp(.)24 b(\(In)16 b(the)h(next)f(Section)0 958 y(w)o(e)f(giv)o(e)g(a)g(fuller)i (de\014nition)g(or)d Fi(Ord)h Fp(tak)o(en)g(from)f(the)i(Standard)f (Prelude.\))71 1035 y(One)24 b(b)q(ene\014t)h(of)e(suc)o(h)h(class)g (inclusions)i(is)e(shorter)f(con)o(texts:)36 b(A)24 b(t)o(yp)q(e)f (expression)i(for)e(a)g(function)0 1091 y(that)17 b(uses)g(op)q(erations)h (from)e(b)q(oth)h(the)h Fi(Eq)f Fp(and)g Fi(Ord)g Fp(classes)h(can)f(use)h (the)f(con)o(text)g Fi(\(Ord)23 b(a\))p Fp(,)17 b(rather)g(than)0 1147 y Fi(\(Eq)23 b(a,)h(Ord)f(a\))p Fp(,)18 b(since)i Fi(Ord)d Fp(\\implies")j Fi(Eq)o Fp(.)28 b(More)18 b(imp)q(ortan)o(tly)l(,)g(metho)q (ds)g(for)g(sub)q(class)h(op)q(erations)f(can)0 1204 y(assume)13 b(the)h(existence)g(of)f(metho)q(ds)g(for)g(sup)q(erclass)h(op)q(erations.)20 b(F)l(or)12 b(example,)i(the)g Fi(Ord)f Fp(declaration)h(in)g(the)0 1260 y(Standard)h(Prelude)i(con)o(tains)e(this)g(default)h(metho)q(d)g(for)e Fi(\(<\))p Fp(:)166 1364 y Fi(x)24 b(<)f(y)358 b(=)48 b(x)24 b(<=)f(y)h(&&)g(x)f(/=)h(y)71 1518 y Fp(As)15 b(an)g(example)h(of)f(the)g (use)g(of)g Fi(Ord)p Fp(,)g(the)g(principal)i(t)o(yping)f(of)f Fi(quicksort)f Fp(de\014ned)i(in)g(Section)g(2.5.1)e(is:)71 1629 y Fi(quicksort)356 b(::)48 b(\(Ord)23 b(a\))h(=>)f([a])h(->)f([a])0 1738 y Fp(In)g(other)g(w)o(ords,)g Fi(quicksort)e Fp(only)j(op)q(erates)e(on) h(lists)g(of)f(v)m(alues)i(of)f Fo(or)n(der)n(e)n(d)f Fp(t)o(yp)q(es.)42 b(This)24 b(t)o(yping)f(for)0 1794 y Fi(quicksort)14 b Fp(arises)h(b)q (ecause)h(of)f(the)h(use)f(of)g(the)g(comparison)g(op)q(erators)g Fi(<)g Fp(and)g Fi(>=)g Fp(in)h(its)f(de\014nition.)71 1871 y(Hask)o(ell)21 b(also)g(p)q(ermits)g Fo(multiple)h(inheritanc)n(e)p Fp(,)f(since)h(classes)f(ma)o(y)f(ha)o(v)o(e)g(more)h(than)f(one)h(sup)q (erclass.)0 1927 y(Name)16 b(con\015icts)g(are)g(a)o(v)o(oided)g(b)o(y)f(ha)o (ving)h(the)g(constrain)o(t)f(that)g(a)h(particular)g(op)q(eration)g(can)g(b) q(e)g(a)g(mem)o(b)q(er)0 1984 y(of)f(at)f(most)h(one)g(class)h(in)g(an)o(y)e (giv)o(en)i(scop)q(e.)71 2060 y(Con)o(texts)e(are)h(also)g(allo)o(w)o(ed)g (in)h Fi(data)f Fp(declarations;)h(see)f Fn(x)p Fp(4.2.1.)0 2198 y Fc(A)k(Di\013eren)o(t)f(P)o(ersp)q(ectiv)o(e.)44 b Fp(Before)17 b(going)g(on)f(to)g(further)h(examples)g(of)f(the)h(use)g(of)g(t)o(yp)q(e)f (classes,)i(it)e(is)0 2255 y(w)o(orth)c(p)q(oin)o(ting)i(out)f(t)o(w)o(o)e (other)i(viewp)q(oin)o(ts)h(of)f(Hask)o(ell's)g(t)o(yp)q(e)g(classes.)20 b(The)13 b(\014rst)g(is)g(b)o(y)g(analogy)g(to)f(ob)s(ject-)0 2311 y(orien)o(ted)j(programming)f(\(OOP\).)h(In)g(the)g(follo)o(wing)g (general)h(statemen)o(t)d(ab)q(out)i(OOP)l(,)g(simply)h(substituting)0 2368 y Fo(typ)n(e)g(class)e Fp(for)h(class,)g(and)g Fo(typ)n(e)h Fp(for)e(ob)s(ject,)g(yields)j(a)e(v)m(alid)i(summary)e(of)f(Hask)o(ell's)i (t)o(yp)q(e)f(class)h(mec)o(hanism:)71 2444 y(\\)p Fo(Classes)c Fp(capture)j(common)g(sets)f(of)h Fo(op)n(er)n(ations)p Fp(.)k(A)c (particular)g Fo(obje)n(ct)g Fp(ma)o(y)f(b)q(e)i(an)f Fo(instanc)n(e)e Fp(of)h(a)h(class,)0 2501 y(and)i(will)i(ha)o(v)o(e)d(a)h Fo(metho)n(d)g Fp(corresp)q(onding)h(to)e(eac)o(h)h(op)q(eration.)25 b(Classes)17 b(ma)o(y)f(b)q(e)h(arranged)g(hierarc)o(hically)l(,)0 2557 y(forming)e(notions)g(of)g Fo(sup)n(er)n(classes)e Fp(and)j Fo(sub)n(classes)p Fp(,)d(and)i(p)q(ermitting)h Fo(inheritanc)n(e)e Fp(of)h(op)q(erations/metho)q(ds.)0 2614 y(A)g Fo(default)i(metho)n(d)f Fp(ma)o(y)e(also)h(b)q(e)h(asso)q(ciated)g(with)f(an)g(op)q(eration.")p eop %%Page: 26 26 bop 0 -40 a Fp(T-26)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")71 105 y Fp(In)h Fo(c)n(ontr)n(ast)e Fp(to)h(OOP)l(,)h(it)g (should)g(b)q(e)g(clear)g(that)f(t)o(yp)q(es)h(are)f(not)g(ob)s(jects,)f(and) i(in)g(particular)g(there)g(is)g(no)0 162 y(notion)f(of)g(an)f(ob)s(ject's)g (or)h(t)o(yp)q(e's)f(in)o(ternal)i(m)o(utable)f(state.)k(An)c(adv)m(an)o (tage)g(o)o(v)o(er)f(OOP)h(is)h(that)e(metho)q(ds)h(in)0 218 y(Hask)o(ell)i(are)f(completely)i(t)o(yp)q(e-safe:)k(an)o(y)17 b(attempt)e(to)h(apply)h(a)f(metho)q(d)h(to)f(a)g(v)m(alue)h(whose)g(t)o(yp)q (e)f(is)h(not)f(in)0 274 y(the)f(required)h(class)f(will)h(b)q(e)f(detected)h (at)e(compile)i(time)f(instead)g(of)f(at)g(run)o(time.)21 b(In)15 b(other)f(w)o(ords,)g(metho)q(ds)0 331 y(are)h(not)g(\\lo)q(ok)o(ed)g(up")g (at)g(run)o(time)h(but)f(are)g(simply)h(passed)g(as)f(higher-order)g (functions.)71 428 y(A)d(di\013eren)o(t)g(p)q(ersp)q(ectiv)o(e)h(can)f(b)q(e) h(gotten)e(b)o(y)h(considering)h(the)f(relationship)i(b)q(et)o(w)o(een)e (parametric)g(and)g(ad)0 485 y(ho)q(c)k(p)q(olymorphism.)21 b(W)l(e)16 b(ha)o(v)o(e)f(sho)o(wn)g(ho)o(w)f(parametric)i(p)q(olymorphism)g (is)g(useful)h(in)f(de\014ning)h(families)f(of)0 541 y(t)o(yp)q(es)c(b)o(y)f (univ)o(ersally)j(quan)o(tifying)e(o)o(v)o(er)f Fo(al)r(l)h Fp(t)o(yp)q(es.)18 b(Sometimes,)13 b(ho)o(w)o(ev)o(er,)e(that)g(univ)o(ersal) i(quan)o(ti\014cation)f(is)0 597 y(to)q(o)h(broad|w)o(e)h(wish)h(to)e(quan)o (tify)h(o)o(v)o(er)f(some)h(smaller)g(set)g(of)f(t)o(yp)q(es,)h(suc)o(h)g(as) g(those)g(t)o(yp)q(es)f(whose)h(elemen)o(ts)0 654 y(can)j(b)q(e)h(compared)f (for)f(equalit)o(y)l(.)26 b(T)o(yp)q(e)17 b(classes)h(can)f(b)q(e)h(seen)f (as)g(pro)o(viding)h(a)e(structured)h(w)o(a)o(y)f(to)g(do)h(just)0 710 y(this.)j(Indeed,)c(w)o(e)f(can)g(think)g(of)f(parametric)h(p)q (olymorphism)h(as)e(a)h(kind)h(of)e(o)o(v)o(erloading)h(to)q(o!)k(It's)14 b(just)h(that)0 767 y(the)k(o)o(v)o(erloading)g(o)q(ccurs)g(implicitly)j(o)o (v)o(er)c(all)i(t)o(yp)q(es)e(instead)i(of)e(a)h(constrained)g(set)g(of)f(t)o (yp)q(es)h(\(i.e.)f(a)h(t)o(yp)q(e)0 823 y(class\).)71 920 y(In)g(the)g(remainder)h(of)e(this)h(section)h(w)o(e)f(in)o(tro)q(duce)g(the) g(sev)o(eral)g(prede\014ned)i Fo(standar)n(d)e Fp(t)o(yp)q(e)g(classes)g(in)0 977 y(Hask)o(ell.)0 1176 y Fg(5.1)56 b(Equalit)n(y)17 b(and)i(Ordered)f (Classes)0 1310 y Fp(Hask)o(ell's)c(standard)e(classes)i(form)e(the)h (somewhat)f(frigh)o(tening)i(inclusion)i(structure)d(sho)o(wn)f(in)i(Figure)g (2.)k(A)o(t)0 1367 y(the)e(top)f(of)g(the)g(\014gure,)h(w)o(e)f(see)h Fi(Eq)f Fp(with)h(its)g(sub)q(class)g Fi(Ord)f Fp(b)q(elo)o(w)h(it.)21 b(These)16 b(w)o(ere)f(de\014ned)i(in)g(the)e(previous)0 1423 y(section.)20 b(Con)o(tin)o(uing)c(do)o(wn,)f(w)o(e)g(encoun)o(ter)g(t)o(w)o (o)f(sub)q(classes)j(of)d Fi(Ord)p Fp(,)h Fi(Enum)f Fp(and)i Fi(Ix)o Fp(.)0 1623 y Fg(5.2)56 b(En)n(umeration)17 b(and)i(Index)f(Classes)0 1757 y Fi(Enum)13 b Fp(has)g(a)h(set)f(of)g(op)q(erations)h(that)f(underlie)i (the)f(syn)o(tactic)f(sugar)g(of)h(arithmetic)g(sequences;)h(for)d(example,)0 1813 y(the)j(arithmetic)g(sequence)h(expression)f Fi([1,3..])f Fp(stands)h(for)f Fi(enumFromThen)22 b(1)i(3)14 b Fp(\(see)h Fn(x)p Fp(3.9)f(for)g(the)g(formal)0 1870 y(translation\).)29 b(Arithmetic)20 b(sequences)f(are)g(ordered,)g(so)f(naturally)l(,)h Fi(Enum)f Fp(is)h(a)f(sub)q(class)i(of)e Fi(Ord)p Fp(.)29 b(W)l(e)19 b(can)0 1926 y(no)o(w)d(see)h(that)f(arithmetic)i(sequence)f(expressions)h (can)f(b)q(e)g(used)g(to)f(generate)h(lists)g(of)g(an)o(y)f(t)o(yp)q(e)h (that)f(is)h(an)0 1983 y(instance)f(of)g Fi(Enum)o Fp(.)21 b(This)16 b(includes)i(not)e(only)g(most)f(n)o(umeric)h(t)o(yp)q(es,)f(but)h (also)g Fi(Char)o Fp(,)g(so)f(that,)g(for)g(instance,)0 2039 y Fi(['a'..'z'])g Fp(denotes)h(the)g(list)h(of)f(lo)o(w)o(er-case)f(letters)i (in)g(alphab)q(etical)h(order.)k(F)l(urthermore,)15 b(user-de\014ned)0 2096 y(en)o(umerated)g(t)o(yp)q(es)h(lik)o(e)g Fi(Color)e Fp(can)i(easily)g (b)q(e)g(giv)o(en)f Fi(Enum)g Fp(instance)h(declarations.)21 b(If)15 b(so:)318 2221 y Fi([Red..Violet])72 b Fn(\))h Fi([Red,)24 b(Green,)f(Blue,)g(Indigo,)g(Violet])0 2347 y Fp(Note)13 b(that)g(suc)o(h)h (a)g(sequence)h(is)f Fo(arithmetic)g Fp(in)h(the)f(sense)g(that)f(the)h (incremen)o(t)g(b)q(et)o(w)o(een)g(v)m(alues)h(is)f(constan)o(t,)0 2404 y(ev)o(en)i(though)f(the)g(v)m(alues)h(are)f(not)g(n)o(um)o(b)q(ers.)71 2501 y(The)j(other)h(immediate)g(standard)f(sub)q(class)i(of)e Fi(Ord)g Fp(is)h Fi(Ix)p Fp(,)g(whic)o(h)g(is)g(the)g(class)g(of)f(t)o(yp)q (es)h(that)f(can)g(b)q(e)0 2557 y(used)d(as)g(arra)o(y)e(indices.)22 b(Again,)15 b(it)g(is)g(natural)f(that)g Fi(Ix)h Fp(should)g(b)q(e)h(a)e(sub) q(class)i(of)e Fi(Ord)p Fp(,)g(since)i(w)o(e)e(exp)q(ect)i(the)0 2614 y(elemen)o(ts)g(of)f(an)g(arra)o(y)f(to)g(ha)o(v)o(e)h(an)g(index)i (order.)i(W)l(e)d(deal)g(with)f(class)h Fi(Ix)e Fp(in)j(Section)f(6.9.)p eop %%Page: 27 27 bop 0 -40 a Fj(5.3)45 b(T)l(ext)15 b(and)g(Binary)h(Classes)1267 b Fp(T-27)793 675 y Fa(#)751 708 y(#)741 717 y(#)943 525 y(#)901 558 y(#)891 567 y(#)1074 375 y(#)1033 409 y(#)1022 417 y(#)1093 675 y(#)1051 708 y(#)1041 717 y(#)1187 825 y(#)1145 858 y(#)1134 867 y(#)816 534 y(S)841 567 y(S)816 234 y(S)847 275 y(S)878 317 y(S)909 358 y(S)940 400 y(S)953 417 y(S)1022 833 y(S)1047 867 y(S)1041 534 y(S)1066 567 y(S)1153 684 y(S)1178 717 y(S)909 684 y(S)934 717 y(S)546 609 y(S)577 650 y(S)608 692 y(S)627 717 y(S)631 384 y(\023)600 425 y(\023)569 467 y(\023)549 492 y(\023)728 234 y(\023)703 267 y(\023)703 384 y(S)728 417 y(S)1022 923 y Fi(RealFloat)591 773 y(Integral)389 b(Floating)-473 b(RealFrac)1022 623 y(Fractional)516 548 y(Ix)816 623 y(Real)966 473 y(Num)-279 b(Enum)628 323 y(Ord)759 173 y(Eq)1097 323 y(Text)185 b(Binary)468 1071 y Fp(Figure)16 b(2:)j(Hask)o(ell's)d(Standard)f(T)o(yp)q(e)g(Class)h (Hierarc)o(h)o(y)0 1254 y Fg(5.3)56 b(T)-5 b(ext)18 b(and)h(Binary)f(Classes) 0 1438 y Fc(5.3.1)52 b(T)l(ext)17 b(Class)0 1622 y Fp(The)h(instances)h(of)e (class)h Fi(Text)f Fp(are)h(those)f(t)o(yp)q(es)h(that)f(can)h(b)q(e)g(con)o (v)o(erted)g(to)f(c)o(haracter)g(strings)h(\(t)o(ypically)0 1678 y(for)e(I/O\))h(and)g(bac)o(k;)f(th)o(us,)h(this)g(class)g(pro)o(vides)g (op)q(erations)g(for)f(parsing)h(c)o(haracter)f(strings)g(to)g(obtain)h(the)0 1735 y(v)m(alues)j(they)f(ma)o(y)f(represen)o(t)h(and)g(for)f(pro)q(ducing)j (the)e(canonical)h(textual)f(represen)o(tation)g(of)f(a)h(prin)o(table)0 1791 y(v)m(alue.)i(As)14 b(these)g(primitiv)o(e)i(op)q(erations)e(are)g (somewhat)g(esoteric,)g(let's)g(b)q(egin)i(with)e(one)h(of)e(the)i (higher-lev)o(el)0 1848 y(functions)h(that)e(is)i(de\014ned)h(in)f(terms)e (of)h(them:)71 1948 y Fi(show)476 b(::)24 b(\(Text)f(a\))h(=>)f(a)h(->)g (String)0 2057 y Fp(Naturally)16 b(enough,)f Fi(show)f Fp(tak)o(es)h(an)o(y)f (v)m(alue)j(of)d(an)h(appropriate)h(t)o(yp)q(e)f(and)g(returns)g(its)g (represen)o(tation)h(as)e(a)0 2113 y(c)o(haracter)i(string)g(\(list)h(of)f(c) o(haracters\),)f(as)h(in)h Fi(show)23 b(\(2+2\))o Fp(,)16 b(whic)o(h)i (results)e(in)h Fi("4")p Fp(.)23 b(This)17 b(is)g(\014ne)g(as)f(far)f(as)0 2170 y(it)h(go)q(es,)e(but)i(w)o(e)f(t)o(ypically)i(need)f(to)f(pro)q(duce)h (more)f(complex)h(strings)f(that)g(ma)o(y)g(ha)o(v)o(e)g(the)g(represen)o (tations)0 2226 y(of)g(man)o(y)g(v)m(alues)h(in)g(them,)f(as)f(in)71 2335 y Fi("The)23 b(sum)g(of)h(")g(++)f(show)h(x)f(++)h(")g(and)f(")h(++)f (show)h(y)f(++)h(")g(is)f(")h(++)g(show)f(\(x+y\))g(++)h(".")0 2444 y Fp(and)18 b(after)f(a)g(while,)j(all)f(that)e(concatenation)h(gets)f (to)g(b)q(e)h(a)g(bit)g(ine\016cien)o(t.)29 b(Sp)q(eci\014call)q(y)l(,)21 b(let's)d(consider)g(a)0 2501 y(function)h(to)f(represen)o(t)g(the)g(binary)h (trees)f(of)g(Section)h(2.3)e(as)h(a)f(string,)i(with)f(suitable)i(markings)e (to)g(sho)o(w)0 2557 y(the)d(nesting)h(of)e(subtrees)i(and)f(the)g (separation)g(of)f(left)i(and)f(righ)o(t)g(branc)o(hes)g(\(pro)o(vided)h(the) f(elemen)o(t)g(t)o(yp)q(e)g(is)0 2614 y(represen)o(table)h(as)f(a)g (string\):)p eop %%Page: 28 28 bop 0 -40 a Fp(T-28)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")71 160 y Fi(showTree)380 b(::)24 b(\(Text)f(a\))h(=>)f(Tree)h (a)f(->)h(String)71 216 y(showTree)e(\(Leaf)i(x\))166 b(=)48 b(show)23 b(x)71 272 y(showTree)f(\(Branch)h(l)h(r\))71 b(=)48 b("<")23 b(++)h(showTree)f(l)g(++)h("|")f(++)h(showTree)f(r)h(++)f(">")0 382 y Fp(Because)16 b Fi(\(++\))f Fp(has)g(time)h(complexit)o(y)g(linear)h (in)f(the)f(length)h(of)f(its)h(left)f(argumen)o(t,)g Fi(showTree)f Fp(is)i(quadratic)0 438 y(in)g(the)f(size)h(of)f(the)g(tree.)71 531 y(T)l(o)f(restore)h(linear)h(complexit)o(y)l(,)g(the)g(function)g Fi(shows)e Fp(is)i(pro)o(vided:)71 640 y Fi(shows)452 b(::)24 b(\(Text)f(a\))h(=>)f(a)h(->)g(String)f(->)g(String)0 749 y(shows)15 b Fp(tak)o(es)g(a)h(prin)o(table)h(v)m(alue)g(and)f(a)f(string)h(and)g (returns)g(that)f(string)h(with)g(the)g(v)m(alue's)h(represen)o(tation)0 805 y(concatenated)f(at)g(the)g(fron)o(t.)22 b(The)16 b(second)h(argumen)o(t) e(serv)o(es)h(as)g(a)g(sort)f(of)h(string)g Fo(ac)n(cumulator,)h Fp(and)g Fi(show)0 862 y Fp(can)e(no)o(w)g(b)q(e)h(de\014ned)g(as)f Fi(shows)g Fp(with)g(the)h(n)o(ull)g(accum)o(ulator:)71 962 y Fi(show)23 b(x)429 b(=)48 b(shows)23 b(x)h("")0 1071 y Fp(W)l(e)16 b(can)g(use)g Fi(shows)f Fp(to)g(de\014ne)i(a)e(more)g(e\016cien)o(t)i(v)o (ersion)f(of)f Fi(showTree)o Fp(,)h(whic)o(h)g(also)g(has)f(a)h(string)g (accum)o(u-)0 1128 y(lator)f(argumen)o(t:)71 1237 y Fi(showsTree)356 b(::)24 b(\(Text)f(a\))h(=>)f(Tree)h(a)f(->)h(String)f(->)h(String)71 1293 y(showsTree)e(\(Leaf)h(x\))h(s)95 b(=)48 b(shows)23 b(x)h(s)71 1349 y(showsTree)e(\(Branch)h(l)h(r\))f(s=)48 b('<')23 b(:)h(showsTree)f(l)g (\('|')h(:)f(showsTree)g(r)h(\('>')f(:)h(s\)\))0 1461 y Fp(This)16 b(solv)o(es)f(our)g(e\016ciency)i(problem)f(\()p Fi(showsTree)e Fp(has)h(linear)h(complexit)o(y\),)g(but)f(the)g(presen)o(tation)h(of)f(this) 0 1518 y(function)h(\(and)f(others)g(lik)o(e)h(it\))f(can)h(b)q(e)g(impro)o (v)o(ed.)k(First,)14 b(let's)h(create)g(a)g(t)o(yp)q(e)g(synon)o(ym:)71 1629 y Fi(type)23 b(ShowS)333 b(=)48 b(String)23 b(->)h(String)0 1738 y Fp(This)d(is)f(the)g(t)o(yp)q(e)g(of)g(a)f(function)i(that)f(returns)f (a)h(string)g(represen)o(tation)g(of)g(something)g(follo)o(w)o(ed)g(b)o(y)g (an)0 1795 y(accum)o(ulator)15 b(string.)21 b(Second,)c(w)o(e)e(can)h(a)o(v)o (oid)f(carrying)h(accum)o(ulators)f(around,)g(and)h(also)g(a)o(v)o(oid)f (amassing)0 1851 y(paren)o(theses)g(at)g(the)g(righ)o(t)g(end)h(of)f(long)g (constructions,)g(b)o(y)g(using)h(functional)h(comp)q(osition:)71 1960 y Fi(showsTree)356 b(::)24 b(\(Text)f(a\))h(=>)f(Tree)h(a)f(->)h(ShowS) 71 2016 y(showsTree)e(\(Leaf)h(x\))143 b(=)48 b(shows)23 b(x)71 2073 y(showsTree)f(\(Branch)h(l)h(r\))47 b(=)h(\('<':\))23 b(.)h(showsTree)e(l)i(.)g(\('|':\))f(.)h(showsTree)e(r)i(.)g(\('>':\))0 2182 y Fp(Something)16 b(more)g(imp)q(ortan)o(t)g(than)f(just)h(tidying)h(up) f(the)g(co)q(de)h(has)f(come)g(ab)q(out)f(b)o(y)h(this)h(transformation:)0 2238 y(W)l(e)f(ha)o(v)o(e)f(raised)h(the)g(presen)o(tation)g(from)e(an)i Fo(obje)n(ct)g(level)f Fp(\(in)h(this)g(case,)g(strings\))f(to)g(a)g Fo(function)h(level.)21 b Fp(W)l(e)0 2295 y(can)16 b(think)h(of)e(the)h(t)o (yping)h(as)e(sa)o(ying)h(that)f Fi(showsTree)g Fp(maps)h(a)f(tree)h(in)o(to) g(a)g Fo(showing)g(function)p Fp(.)22 b(F)l(unctions)0 2351 y(lik)o(e)16 b Fi(\('<')23 b(:\))14 b Fp(or)g Fi(\("a)23 b(string")g(++\))14 b Fp(are)g(primitiv)o(e)i(sho)o(wing)e(functions,)h(and)g(w)o(e)f(build)i(up) f(more)f(complex)0 2408 y(functions)i(b)o(y)f(comp)q(osition.)71 2501 y(No)o(w)i(that)g(w)o(e)h(can)g(turn)g(trees)g(in)o(to)g(strings,)g (let's)g(turn)g(to)g(the)g(in)o(v)o(erse)g(problem.)30 b(The)18 b(basic)h(idea)f(is)0 2557 y(a)g Fo(p)n(arser)h Fp(for)f(a)g(t)o(yp)q(e)h Fi(a)p Fp(,)g(whic)o(h)g(is)h(a)e(function)h(that)f(tak)o(es)g(a)h(string)f (and)h(returns)f(a)h(list)g(of)g Fi(\(a,)k(String\))0 2614 y Fp(pairs[7].)c(The)d(Standard)f(Prelude)h(pro)o(vides)g(a)f(t)o(yp)q(e)g (synon)o(ym)g(for)f(suc)o(h)i(functions:)p eop %%Page: 29 29 bop 0 -40 a Fj(5.3)45 b(T)l(ext)15 b(and)g(Binary)h(Classes)1267 b Fp(T-29)71 160 y Fi(type)23 b(ReadS)g(a)286 b(=)48 b(String)23 b(->)h([\(a,String\)])0 269 y Fp(Normally)l(,)13 b(a)f(parser)f(returns)h(a)g (singleton)h(list,)g(con)o(taining)f(a)g(v)m(alue)h(of)f(t)o(yp)q(e)g Fi(a)f Fp(that)h(w)o(as)f(read)h(from)f(the)h(input)0 325 y(string)g(and)g (the)g(remaining)i(string)e(that)f(follo)o(ws)h(what)g(w)o(as)f(parsed.)19 b(If)12 b(no)g(parse)g(w)o(as)f(p)q(ossible,)j(ho)o(w)o(ev)o(er,)e(the)0 382 y(result)k(is)h(the)f(empt)o(y)f(list,)i(and)f(if)g(there)g(is)g(more)g (than)g(one)g(p)q(ossible)h(parse)f(\(an)f(am)o(biguit)o(y\),)h(the)g (resulting)0 438 y(list)e(con)o(tains)g(more)f(than)g(one)h(pair.)20 b(The)14 b(standard)f(function)h Fi(reads)f Fp(is)h(a)f(parser)g(for)g(an)o (y)g(instance)i(of)e Fi(Text)o Fp(:)71 547 y Fi(reads)452 b(::)24 b(\(Text)f(a\))h(=>)f(ReadS)g(a)0 656 y Fp(W)l(e)16 b(can)h(use)g(this)f (function)i(to)d(de\014ne)j(a)e(parsing)g(function)i(for)d(the)i(string)f (represen)o(tation)g(of)g(binary)h(trees)0 713 y(pro)q(duced)k(b)o(y)f Fi(showsTree)n Fp(.)34 b(List)21 b(comprehensions)g(giv)o(e)f(us)g(a)f(con)o (v)o(enien)o(t)h(idiom)h(for)f(constructing)g(suc)o(h)0 769 y(parsers:)71 878 y Fi(readsTree)356 b(::)24 b(\(Text)f(a\))h(=>)f(ReadS)g (\(Tree)h(a\))71 934 y(readsTree)e(\('<':s\))166 b(=)48 b([\(Branch)23 b(l)g(r,)h(u\))g(|)f(\(l,)h('|':t\))f(<-)g(readsTree)g(s,)1168 991 y(\(r,)h('>':u\))f(<-)g(readsTree)g(t)h(])71 1047 y(readsTree)e(s)310 b(=)48 b([\(Leaf)23 b(x,)h(t\))119 b(|)23 b(\(x,t\))143 b(<-)23 b(reads)h(s])0 1156 y Fp(Let's)19 b(tak)o(e)f(a)g(momen)o(t)g(to)h(examine)g (this)h(function)f(de\014nition)i(in)f(detail.)31 b(There)20 b(are)e(t)o(w)o(o)g(main)h(cases)g(to)0 1213 y(consider:)i(If)15 b(the)g(\014rst)g(c)o(haracter)f(of)h(the)g(string)g(to)f(b)q(e)i(parsed)f (is)g Fi('<')p Fp(,)g(w)o(e)f(should)i(ha)o(v)o(e)f(the)g(represen)o(tation)0 1269 y(of)e(a)g(branc)o(h;)g(otherwise,)h(w)o(e)f(ha)o(v)o(e)f(a)h(leaf.)20 b(In)14 b(the)f(\014rst)g(case,)g(calling)i(the)e(rest)g(of)g(the)g(input)h (string)f(follo)o(wing)0 1326 y(the)j(op)q(ening)h(angle)f(brac)o(k)o(et)f Fi(s)p Fp(,)g(an)o(y)h(p)q(ossible)h(parse)f(m)o(ust)f(b)q(e)h(a)f(tree)h Fi(Branch)23 b(l)h(r)15 b Fp(with)h(remaining)h(string)0 1382 y Fi(u)p Fp(,)e(sub)s(ject)g(to)f(the)i(follo)o(wing)f(conditions:)56 1510 y(1.)22 b(The)15 b(tree)g Fi(l)g Fp(can)g(b)q(e)h(parsed)g(from)e(the)h (b)q(eginning)j(of)c(the)i(string)f Fi(s)p Fp(.)56 1611 y(2.)22 b(The)14 b(string)f(remaining)i(\(follo)o(wing)f(the)g(represen)o(tation)g (of)f Fi(l)p Fp(\))g(b)q(egins)i(with)g Fi('|')o Fp(.)k(Call)c(the)f(tail)g (of)g(this)114 1668 y(string)h Fi(t)p Fp(.)56 1769 y(3.)22 b(The)15 b(tree)g Fi(r)g Fp(can)g(b)q(e)h(parsed)g(from)e(the)h(b)q(eginning) j(of)c Fi(t)p Fp(.)56 1870 y(4.)22 b(The)15 b(string)g(remaining)h(from)f Fo(that)h Fp(parse)f(b)q(egins)h(with)g Fi('>')o Fp(,)f(and)h Fi(u)f Fp(is)g(the)h(tail.)0 1997 y(Notice)e(the)f(expressiv)o(e)h(p)q(o)o(w) o(er)f(w)o(e)g(get)g(from)g(the)g(com)o(bination)h(of)f(pattern)g(matc)o (hing)g(with)h(list)g(comprehen-)0 2054 y(sion:)22 b(The)16 b(form)f(of)h(a)f(resulting)i(parse)f(is)g(giv)o(en)h(b)o(y)f(the)g(main)g (expression)h(of)e(the)h(list)h(comprehension,)g(the)0 2110 y(\014rst)d(t)o(w)o(o)e(conditions)k(ab)q(o)o(v)o(e)d(are)h(expressed)h(b)o (y)f(the)g(\014rst)f(generator)h(\(\\)p Fi(\(l,)22 b('|':t\))14 b Fp(is)g(dra)o(wn)g(from)f(the)h(list)0 2167 y(of)h(parses)g(of)g Fi(s)o Fp(."\),)f(and)i(the)f(remaining)h(conditions)h(are)d(expressed)i(b)o (y)f(the)h(second)f(generator.)71 2252 y(The)e(second)g(de\014ning)h (equation)f(ab)q(o)o(v)o(e)f(just)h(sa)o(ys)f(that)g(to)g(parse)g(the)h (represen)o(tation)g(of)f(a)g(leaf,)i(w)o(e)e(parse)0 2308 y(a)k(represen)o(tation)g(of)f(the)i(elemen)o(t)f(t)o(yp)q(e)h(of)e(the)h (tree)g(and)h(apply)f(the)h(constructor)e Fi(Leaf)g Fp(to)h(the)g(v)m(alue)h (th)o(us)0 2365 y(obtained.)71 2450 y(W)l(e'll)f(accept)h(on)e(faith)h(for)g (the)g(momen)o(t)f(that)g(there)h(is)h(a)e Fi(Text)g Fp(instance)i(of)f Fi(Int)f Fp(\(among)g(man)o(y)g(other)0 2506 y(t)o(yp)q(es\),)g(pro)o(viding) h(a)f Fi(reads)f Fp(that)g(b)q(eha)o(v)o(es)i(as)f(one)g(w)o(ould)h(exp)q (ect,)f(e.g.:)115 2614 y Fi(\(reads)23 b("5)h(golden)f(rings"\))g(::)h ([\(Int,String\)])71 b Fn(\))j Fi([\(5,)23 b(")h(golden)f(rings"\)])p eop %%Page: 30 30 bop 0 -40 a Fp(T-30)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")0 105 y Fp(With)g(this)h(understanding,)g(the)f(reader)g (should)i(v)o(erify)e(the)g(follo)o(wing)h(ev)m(aluations:)21 194 y Fi(readsTree)22 b("<1|<2|3>>")101 b Fn(\))i Fi([\(Branch)22 b(\(Leaf)i(1\))f(\(Branch)g(\(Leaf)g(2\))h(\(Leaf)f(3\)\),)g(""\)])21 251 y(readsTree)f("<1|2")221 b Fn(\))103 b Fi([])71 362 y Fp(Because)19 b(the)g(textual)g(represen)o(tation)f(w)o(e)h(ha)o(v)o(e)f(c)o(hosen)h(for)f (trees)h(is)g(unam)o(biguous,)h Fi(readsTree)d Fp(will)0 418 y(alw)o(a)o(ys)11 b(return)g(either)h(a)f(singleton)i(list)f(or)f(an)g(empt)o (y)g(list,)i(pro)o(vided)f(that)f(the)g(represen)o(tation)h(of)f(the)g (elemen)o(t)0 474 y(t)o(yp)q(e)k(is)g(also)f(unam)o(biguous.)21 b(Supp)q(ose,)15 b(ho)o(w)o(ev)o(er,)f(that)f(w)o(e)i(w)o(ere)f(to)g(c)o (hange)h(our)f(textual)h(represen)o(tation)f(of)0 531 y(trees)h(to)g(omit)g (the)g(angle)h(brac)o(k)o(ets:)71 640 y Fi(readsTree)22 b(s)310 b(=)48 b([\(Branch)23 b(l)g(r,)h(u\))g(|)f(\(l,)h('|':t\))f(<-)g(readsTree)g (s,)1168 696 y(\(r,)h(u\))119 b(<-)23 b(readsTree)g(t)h(])715 753 y(++)715 809 y([\(Leaf)f(x,)h(t\))119 b(|)23 b(\(x,t\))143 b(<-)23 b(reads)h(s])0 921 y Fp(\(The)16 b Fi(\(++\))g Fp(here)h(can)g(b)q(e) g(though)o(t)e(of)h(as)g(a)h(list)g(analogue)f(of)g(set)h(union;)g(that)f (is,)h(the)g(tree)f(parses)g(of)g Fi(s)g Fp(are)0 977 y(all)g(its)g(parses)f (as)f(a)h(branc)o(h)h(plus)g(all)g(its)f(parses)g(as)g(a)g(leaf.\))20 b(No)o(w,)14 b(w)o(e)h(see)h(that:)51 1069 y Fi(readsTree)22 b("1|2|3")102 b Fn(\))g Fi([\(Branch)23 b(\(Branch)g(\(Leaf)g(1\))h(\(Leaf)f (2\)\))g(\(Leaf)g(3\),)h(""\),)730 1125 y(\(Branch)f(\(Leaf)g(1\))h(\(Branch) f(\(Leaf)g(2\))g(\(Leaf)g(3\)\),)h(""\)])71 1236 y Fp(Returning)15 b(to)f(our)g(unam)o(biguous)h(represen)o(tation,)f(there)h(are)f(a)g(couple)h (of)f(shortcomings)g(to)g(deal)h(with.)0 1293 y(One)g(is)g(that)e(the)h (parser)g(is)h(quite)g(rigid,)g(allo)o(wing)g(no)f(white)h(space)f(b)q(efore) h(or)e(b)q(et)o(w)o(een)i(the)f(elemen)o(ts)h(of)f(the)0 1349 y(tree)i(represen)o(tation;)h(the)f(other)g(is)h(that)e(the)i(w)o(a)o(y)e(w)o (e)h(parse)g(our)g(punctuation)h(sym)o(b)q(ols)g(is)g(quite)g(di\013eren)o(t) 0 1406 y(from)10 b(the)g(w)o(a)o(y)g(w)o(e)g(parse)h(leaf)g(v)m(alues)g(and)g (subtrees,)g(this)g(lac)o(k)g(of)f(uniformit)o(y)h(making)g(the)g(function)g (de\014nition)0 1462 y(harder)16 b(to)g(read.)23 b(W)l(e)17 b(can)f(address)h(b)q(oth)f(of)g(these)h(problems)g(b)o(y)f(using)h(the)g (lexical)h(analyzer)f(pro)o(vided)g(b)o(y)0 1519 y(the)e(Standard)g(Prelude:) 71 1619 y Fi(lex)500 b(::)24 b(ReadS)f(String)0 1728 y(lex)c Fp(normally)i(returns)f(a)f(singleton)i(list)g(con)o(taining)g(a)e(pair)i(of) e(strings:)30 b(the)20 b(\014rst)f(lexeme)i(in)g(the)f(input)0 1784 y(string)d(and)g(the)g(remainder)g(of)g(the)g(input.)26 b(The)17 b(lexical)i(rules)e(are)g(those)f(of)h(Hask)o(ell)g(programs,)f (including)0 1841 y(commen)o(ts,)h(whic)o(h)g Fi(lex)g Fp(skips,)h(along)f (with)g(whitespace.)26 b(If)18 b(the)f(input)h(string)f(is)g(empt)o(y)g(or)f (con)o(tains)h(only)0 1897 y(whitespace)e(and)f(commen)o(ts,)f Fi(lex)h Fp(returns)g Fi([\("",""\)])o Fp(;)g(if)g(the)g(input)h(is)g(not)e (empt)o(y)h(in)h(this)f(sense,)h(but)f(also)0 1954 y(do)q(es)i(not)e(b)q (egin)j(with)e(a)g(v)m(alid)i(lexeme)f(after)f(an)o(y)g(leading)h(whitespace) g(and)g(commen)o(ts,)e Fi(lex)h Fp(returns)g Fi([])o Fp(.)71 2032 y(Using)g(the)h(lexical)h(analyzer,)e(our)g(tree)g(parser)g(no)o(w)g(lo) q(oks)g(lik)o(e)h(this:)71 2141 y Fi(readsTree)356 b(::)24 b(\(Text)f(a\))h(=>)f(ReadS)g(\(Tree)h(a\))71 2197 y(readsTree)e(s)310 b(=)48 b([\(Branch)23 b(l)g(r,)h(x\))g(|)f(\("<",)g(t\))h(<-)g(lex)f(s,)1168 2254 y(\(l,)71 b(u\))24 b(<-)g(readsTree)e(t,)1168 2310 y(\("|",)h(v\))h(<-)g (lex)f(u,)1168 2367 y(\(r,)71 b(w\))24 b(<-)g(readsTree)e(v,)1168 2423 y(\(">",)h(x\))h(<-)g(lex)f(w)215 b(])715 2480 y(++)715 2536 y([\(Leaf)23 b(x,)h(t\))119 b(|)23 b(\(x,)71 b(t\))24 b(<-)g(reads)f(s)167 b(])p eop %%Page: 31 31 bop 0 -40 a Fj(5.4)45 b(Deriv)o(ed)15 b(Instances)1402 b Fp(T-31)71 105 y(W)l(e)10 b(ma)o(y)g(no)o(w)h(wish)g(to)f(use)h Fi(readsTree)f Fp(and)h Fi(showsTree)e Fp(to)h(declare)i Fi(\(Text)23 b(a\))h(=>)g(Tree)f(a) 10 b Fp(an)h(instance)0 162 y(of)18 b Fi(Text)o Fp(.)30 b(This)19 b(w)o(ould)f(allo)o(w)h(us)f(to)g(use)h(the)f(generic)h(o)o(v)o(erloaded)g (functions)g(from)e(the)i(Prelude)g(to)f(parse)0 218 y(and)c(displa)o(y)g (trees.)19 b(Moreo)o(v)o(er,)12 b(w)o(e)i(w)o(ould)g(automatically)f(then)h (b)q(e)g(able)h(to)e(parse)g(and)h(displa)o(y)g(man)o(y)f(other)0 274 y(t)o(yp)q(es)k(con)o(taining)g(trees)f(as)g(comp)q(onen)o(ts,)h(for)f (example,)h Fi([Tree)23 b(Int])p Fp(.)h(As)16 b(it)h(turns)f(out,)g Fi(readsTree)g Fp(and)0 331 y Fi(showsTree)c Fp(are)h(of)h(almost)f(the)g (righ)o(t)h(t)o(yp)q(es)f(to)g(b)q(e)h Fi(Text)f Fp(metho)q(ds,)h(needing)h (only)f(the)f(addition)i(of)e(an)h(extra)0 387 y(parameter)f(eac)o(h)g(that)g (has)g(do)h(do)f(with)h(paren)o(thesization)g(of)f(forms)g(with)h(in\014x)h (constructors.)j(W)l(e)c(refer)f(the)0 444 y(in)o(terested)j(reader)f(to)f Fn(x)q Fp(E.2)g(for)h(details.)71 527 y(W)l(e)i(can)g(test)f(suc)o(h)h(a)g Fi(Text)f Fp(instance)i(b)o(y)f(applying)h Fi(\(read)24 b(.)f(show\))16 b Fp(\(whic)o(h)i(should)g(b)q(e)g(the)f(iden)o(tit)o(y\))0 584 y(to)e(some)f(trees,)h(where)g Fi(read)g Fp(is)h(a)f(sp)q(ecialization)i (of)e Fi(reads)p Fp(:)71 693 y Fi(read)476 b(::)24 b(\(Text)f(a\))h(=>)f (String)g(->)h(a)0 802 y Fp(This)c(function)g(fails)h(if)f(there)f(is)h(not)f (a)g(unique)i(parse)f(or)f(if)h(the)f(input)i(con)o(tains)e(an)o(ything)h (more)f(than)g(a)0 858 y(represen)o(tation)c(of)g(one)g(v)m(alue)i(of)e(t)o (yp)q(e)g Fi(a)g Fp(\(and)g(p)q(ossibly)l(,)h(commen)o(ts)f(and)g (whitespace\).)0 1010 y Fc(5.3.2)52 b(Binary)17 b(Class)0 1123 y Fp(The)e Fi(Binary)f Fp(class)i(is)f(similar)h(to)f Fi(Text)o Fp(,)g(but)g(uses)g(a)g(primitiv)o(e)h(abstract)e(t)o(yp)q(e)h Fi(Bin)g Fp(instead)g(of)g Fi(String)o Fp(,)g(the)0 1180 y(purp)q(ose)f(of)g (whic)o(h)g(is)h(e\016cien)o(t)f(transparen)o(t)f(I/O.)h(\(See)g Fn(x)p Fp(7.\))19 b(Generally)l(,)c(only)f(deriv)o(ed)h(instances)f(of)g Fi(Binary)0 1236 y Fp(are)22 b(used)g(\(see)g(b)q(elo)o(w\),)h(whic)o(h)g (generate)e(implemen)o(tation-de\014ned)k(op)q(erations)d Fi(readBin)f Fp(and)h Fi(showBin)0 1293 y Fp(\(analogous)15 b(to)f Fi(reads)h Fp(and)g Fi(shows)o Fp(\).)0 1446 y Fg(5.4)56 b(Deriv)n(ed)17 b(Instances)0 1560 y Fp(Recall)12 b(the)f Fi(Eq)f Fp(instance)i(for)e(trees)g (w)o(e)h(presen)o(ted)g(in)g(Section)h(5;)f(suc)o(h)g(a)g(declaration)g(is)g (simple|and)i(b)q(oring|)0 1616 y(to)f(pro)q(duce:)20 b(W)l(e)12 b(require)i(that)e(the)h(elemen)o(t)g(t)o(yp)q(e)g(in)h(the)e(lea)o(v)o(es)h (b)q(e)h(an)e(equalit)o(y)i(t)o(yp)q(e;)f(then,)g(t)o(w)o(o)e(lea)o(v)o(es)i (are)0 1673 y(equal)18 b(i\013)f(they)h(con)o(tain)f(equal)h(elemen)o(ts,)g (and)f(t)o(w)o(o)f(branc)o(hes)i(are)f(equal)h(i\013)f(their)h(left)f(and)h (righ)o(t)f(subtrees)0 1729 y(are)e(equal,)g(resp)q(ectiv)o(ely)l(.)22 b(An)o(y)15 b(other)g(t)o(w)o(o)f(trees)h(are)g(unequal:)71 1838 y Fi(instance)46 b(\(Eq)24 b(a\))f(=>)h(Eq)f(\(Tree)h(a\))47 b(where)166 1895 y(\(Leaf)23 b(x\))119 b(==)24 b(\(Leaf)f(y\))191 b(=)47 b(x)24 b(==)g(y)166 1951 y(\(Branch)f(l)h(r\))f(==)h(\(Branch)f(l')g (r'\))48 b(=)f(l)24 b(==)g(l')f(&&)h(r)f(==)h(r')166 2008 y(_)286 b(==)24 b(_)358 b(=)47 b(False)71 2168 y Fp(F)l(ortunately)l(,)13 b(w)o(e)g(don't)g(need)i(to)e(go)g(through)g(this)h(tedium)g(ev)o(ery)g(time) g(w)o(e)f(need)i(equalit)o(y)f(op)q(erators)f(for)0 2225 y(a)f(new)i(t)o(yp)q (e;)f(the)g Fi(Eq)f Fp(instance)i(can)f(b)q(e)g Fo(derive)n(d)h(automatic)n (al)r(ly)g Fp(from)e(the)h Fi(data)f Fp(declaration)i(if)f(w)o(e)g(so)f(sp)q (ecify:)71 2335 y Fi(data)47 b(Tree)23 b(a)286 b(=)48 b(Leaf)23 b(a)h(|)g(Branch)f(\(Tree)g(a\))g(\(Tree)h(a\))47 b(deriving)23 b(Eq)0 2444 y Fp(The)16 b Fi(deriving)e Fp(clause)i(implicitly)i(pro)q(duces) e(an)g Fi(Eq)f Fp(instance)h(declaration)g(just)f(lik)o(e)h(the)g(one)f(in)h (Section)h(5.)0 2501 y(Instances)d(of)f Fi(Ord)o Fp(,)h Fi(Enum)o Fp(,)g Fi(Ix)o Fp(,)g Fi(Text)o Fp(,)f(and)h Fi(Binary)e Fp(can)i(also)f(b)q (e)h(generated)g(b)o(y)f(the)h Fi(deriving)e Fp(clause.)20 b([More)0 2557 y(than)d(one)g(class)h(name)f(can)h(b)q(e)g(sp)q(eci\014ed,)h (in)f(whic)o(h)g(case)f(the)h(list)g(of)f(names)g(m)o(ust)f(b)q(e)i(paren)o (thesized)h(and)0 2614 y(the)c(names,)g(separated)g(b)o(y)g(commas.])p eop %%Page: 32 32 bop 0 -40 a Fp(T-32)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")71 105 y Fp(The)g(deriv)o(ed)h Fi(Ord)f Fp(instance)h(for)f Fi(Tree)f Fp(is)i(sligh)o(tly)g(more)f(complicated)h(than)g(the)f Fi(Eq)g Fp(instance:)71 215 y Fi(instance)46 b(\(Ord)24 b(a\))f(=>)h(Ord)f (\(Tree)g(a\))48 b(where)166 272 y(\(Leaf)23 b(_\))119 b(<=)24 b(\(Branch)f(_\))143 b(=)47 b(True)166 328 y(\(Leaf)23 b(x\))119 b(<=)24 b(\(Leaf)f(y\))191 b(=)47 b(x)24 b(<=)g(y)166 385 y(\(Branch)f(_\))71 b(<=)24 b(\(Leaf)f(_\))191 b(=)47 b(False)166 441 y(\(Branch)23 b(l)h(r\))f(<=)h(\(Branch)f(l')g(r'\))48 b(=)f(l)24 b(==)g(l')f(&&)h(r)f(<=)h (r')g(||)f(l)h(<=)g(l')0 550 y Fp(This)17 b(sp)q(eci\014es)i(a)d Fo(lexic)n(o)n(gr)n(aphic)g Fp(order:)23 b(Constructors)15 b(are)i(ordered)g(b)o(y)f(the)h(order)f(of)h(their)g(app)q(earance)g(in)0 607 y(the)f Fi(data)g Fp(declaration,)h(and)g(the)f(argumen)o(ts)g(of)g(a)g (constructor)f(are)i(compared)f(from)g(left)g(to)g(righ)o(t.)23 b(Recall)0 663 y(that)16 b(the)g(built-in)j(list)e(t)o(yp)q(e)g(is)g(seman)o (tically)g(equiv)m(alen)o(t)h(to)e(an)g(ordinary)h(t)o(w)o(o-constructor)d(t) o(yp)q(e.)24 b(In)17 b(fact,)0 720 y(this)f(is)f(the)h(full)g(declaration:)71 820 y Fi(data)23 b([a])190 b(=)24 b([])g(|)f(a)h(:)g([a])f(deriving)g(\(Eq,)g (Ord,)h(Binary\))118 b(--)24 b(pseudocode)0 931 y Fp(\(Lists)16 b(also)f(ha)o(v)o(e)g(a)g Fi(Text)g Fp(instance,)h(whic)o(h)g(is)g(not)f (deriv)o(ed.\))21 b(The)15 b(deriv)o(ed)i Fi(Eq)e Fp(and)g Fi(Ord)g Fp(instances)h(for)f(lists)0 988 y(are)e(the)h(usual)h(ones;)f(in)g (particular,)h(c)o(haracter)e(strings,)h(as)f(lists)h(of)g(c)o(haracters,)f (are)g(ordered)h(as)g(determined)0 1044 y(b)o(y)20 b(the)g(underlying)j Fi(Char)c Fp(t)o(yp)q(e,)i(with)g(an)f(initial)i(substring)f(comparing)f (less)h(than)f(a)g(longer)g(string;)j(for)0 1101 y(example,)16 b Fi("cat")23 b(<)h("catalog")n Fp(.)71 1194 y(In)11 b(practice,)h Fi(Eq)f Fp(and)g Fi(Ord)f Fp(instances)i(are)f(almost)f(alw)o(a)o(ys)g(deriv) o(ed,)j(rather)d(than)h(user-de\014ned.)20 b(In)11 b(fact,)g(w)o(e)0 1250 y(should)16 b(pro)o(vide)f(our)f(o)o(wn)g(de\014nitions)i(of)e(equalit)o (y)i(and)e(ordering)h(predicates)g(only)g(with)g(some)g(trepidation,)0 1307 y(b)q(eing)i(careful)g(to)e(main)o(tain)h(the)g(exp)q(ected)h(algebraic) g(prop)q(erties)f(of)f(equiv)m(alence)k(relations)d(and)g(partial)g(or)0 1363 y(total)h(orders.)28 b(An)19 b(in)o(transitiv)o(e)f Fi(\(==\))g Fp(predicate,)h(for)e(example,)i(could)h(b)q(e)e(disastrous,)g(confusing)h (readers)0 1420 y(of)f(the)g(program)f(and)h(confounding)h(man)o(ual)g(or)e (automatic)h(program)f(transformations)g(that)g(rely)i(on)f(the)0 1476 y Fi(\(==\))i Fp(predicate's)h(b)q(eing)h(an)f(appro)o(ximation)f(to)g (de\014nitional)j(equalit)o(y)l(.)37 b(Nev)o(ertheless,)23 b(it)e(is)g(sometimes)0 1533 y(necessary)16 b(to)f(pro)o(vide)h Fi(Eq)f Fp(or)g Fi(Ord)h Fp(instances)g(di\013eren)o(t)g(from)f(those)g(that) g(w)o(ould)h(b)q(e)g(deriv)o(ed;)h(probably)f(the)0 1589 y(most)h(imp)q (ortan)o(t)h(example)h(is)f(that)g(of)f(an)h(abstract)f(data)h(t)o(yp)q(e)g (in)h(whic)o(h)g(di\013eren)o(t)f(concrete)g(v)m(alues)i(ma)o(y)0 1645 y(represen)o(t)15 b(the)g(same)g(abstract)g(v)m(alue.)71 1738 y(An)h(en)o(umerated)g(t)o(yp)q(e)g(can)g(ha)o(v)o(e)f(a)h(deriv)o(ed)h Fi(Enum)e Fp(instance,)i(and)f(here)g(again,)g(the)g(ordering)g(is)g(that)f (of)0 1795 y(the)g(constructors)g(in)h(the)f Fi(data)g Fp(declaration.)20 b(F)l(or)15 b(example:)71 1904 y Fi(data)23 b(Day)g(=)h(Sunday)f(|)h(Monday)f (|)h(Tuesday)f(|)g(Wednesday)285 1960 y(|)h(Thursday)f(|)h(Friday)f(|)g (Saturday)214 b(deriving)23 b(\(Eq,)g(Ord,)g(Enum\))272 2099 y([Wednesday..Friday])141 b Fn(\))72 b Fi([Wednesday,)22 b(Thursday,)h (Friday])272 2156 y([Monday,)g(Wednesday)f(..])72 b Fn(\))g Fi([Monday,)23 b(Wednesday,)f(Friday])71 2295 y Fp(An)17 b(en)o(umerated)g(t) o(yp)q(e)h(or)e(tuple)i(\(single-constructor\))g(t)o(yp)q(e)f(all)h(of)f (whose)g(comp)q(onen)o(t)g(t)o(yp)q(es)g(ha)o(v)o(e)g Fi(Ix)0 2351 y Fp(instances)f(can)f(ha)o(v)o(e)g(a)g(deriv)o(ed)h Fi(Ix)f Fp(instance.)21 b(\(See)15 b(Section)h Fn(x)q Fp(6.9.\))71 2444 y(Deriv)o(ed)j Fi(Text)f Fp(instances)i(are)e(p)q(ossible)i(for)f(en)o (umerated)g(t)o(yp)q(es)f(and)h(other)g(t)o(yp)q(es)f(all)i(of)e(whose)h (com-)0 2501 y(p)q(onen)o(t)g(t)o(yp)q(es)f(also)g(ha)o(v)o(e)g Fi(Text)g Fp(instances.)30 b(\()p Fi(Text)17 b Fp(instances)i(for)f(most)f (of)h(the)g(standard)g(t)o(yp)q(es,)h(but)f(not)0 2557 y(functions,)d(are)f (pro)o(vided)h(b)o(y)f(the)h(Standard)f(Prelude.\))21 b(The)14 b(textual)h(represen)o(tation)f(de\014ned)i(b)o(y)e(a)g(deriv)o(ed)0 2614 y Fi(Text)21 b Fp(instance)h(is)f(consisten)o(t)h(with)f(the)h(app)q (earance)f(of)g(constan)o(t)g(Hask)o(ell)h(expressions)g(of)f(the)g(t)o(yp)q (e)g(in)p eop %%Page: 33 33 bop 0 -40 a Fj(5.5)45 b(Num)o(b)q(ers)1575 b Fp(T-33)0 105 y(question.)20 b(F)l(or)15 b(example,)h(if)f(w)o(e)g(add)h Fi(Text)e Fp(to)h(the)g Fi(deriving)f Fp(clause)i(for)f(t)o(yp)q(e)g Fi(Day)p Fp(,)f(ab)q(o)o(v)o(e,)h(w)o(e)g(obtain)259 209 y Fi(show)23 b([Monday..Wednesday])71 b Fn(\))i Fi ("[Monday,Tuesday,Wednesday]")0 361 y Fg(5.5)56 b(Num)n(b)r(ers)0 474 y Fp(Hask)o(ell)21 b(pro)o(vides)f(a)g(ric)o(h)g(collection)i(of)d(n)o (umeric)i(t)o(yp)q(es,)f(based)h(on)e(those)h(of)f(Sc)o(heme[5],)i(whic)o(h)f (in)h(turn)0 530 y(are)15 b(based)h(on)f(Common)g(Lisp[6)q(].)20 b(\(Those)15 b(languages,)g(ho)o(w)o(ev)o(er,)g(are)g(dynamically)i(t)o(yp)q (ed.\))k(The)15 b(standard)0 587 y(t)o(yp)q(es)j(include)j(\014xed-)e(and)f (arbitrary-precision)h(in)o(tegers,)g(ratios)f(\(rational)f(n)o(um)o(b)q (ers\))i(formed)e(from)h(eac)o(h)0 643 y(in)o(teger)c(t)o(yp)q(e,)g(and)g (single-)h(and)f(double-precision)j(real)d(and)g(complex)h(\015oating-p)q (oin)o(t.)20 b(W)l(e)14 b(outline)h(here)f(the)0 700 y(basic)i(c)o (haracteristics)f(of)g(the)g(n)o(umeric)i(t)o(yp)q(e)e(class)g(structure)g (and)h(refer)f(the)g(reader)g(to)g Fn(x)p Fp(6.8)f(for)h(details.)0 850 y Fc(5.5.1)52 b(Numeric)17 b(Class)g(Structure)0 963 y Fp(Returning)f(to)f(Figure)g(2,)f(w)o(e)h(notice)g(that)g(the)g(n)o(umeric)h (t)o(yp)q(e)f(classes)g(\(class)g Fi(Num)g Fp(and)g(those)g(that)f(lie)i(b)q (elo)o(w)0 1019 y(it\))h(accoun)o(t)f(for)g(more)g(than)h(half)g(of)f(the)h (standard)f(classes.)24 b(W)l(e)17 b(also)g(note)f(that)g Fi(Num)g Fp(is)h(a)g(sub)q(class)g(of)g Fi(Eq)o Fp(,)0 1076 y(but)c(not)f(of)h Fi(Ord)o Fp(;)h(this)f(is)g(b)q(ecause)h(the)f(order)f(predicates)i(do)f(not) f(apply)i(to)e(complex)i(n)o(um)o(b)q(ers.)19 b(The)13 b(sub)q(class)0 1132 y Fi(Real)i Fp(of)f Fi(Num)p Fp(,)h(ho)o(w)o(ev)o(er,)f(is)h(a)g(sub)q (class)i(of)d Fi(Ord)h Fp(as)g(w)o(ell.)71 1215 y(The)k Fi(Num)f Fp(class)i(pro)o(vides)f(sev)o(eral)g(basic)h(op)q(erations)f(common)g(to)f (all)i(n)o(umeric)g(t)o(yp)q(es;)h(these)e(include,)0 1271 y(among)14 b(others,)h(addition,)h(subtraction,)f(negation,)g(m)o (ultiplication,)i(and)e(absolute)h(v)m(alue:)71 1380 y Fi(\(+\),)23 b(\(-\),)g(\(*\))262 b(::)24 b(\(Num)f(a\))h(=>)f(a)h(->)g(a)f(->)h(a)71 1437 y(negate,)e(abs)310 b(::)24 b(\(Num)f(a\))h(=>)f(a)h(->)g(a)0 1548 y Fp([)p Fi(negate)10 b Fp(is)h(the)g(function)h(applied)h(b)o(y)e(Hask) o(ell's)g(only)h(pre\014x)f(op)q(erator,)g(min)o(us;)i(w)o(e)d(can't)h(call)h (it)f Fi(\(-\))p Fp(,)g(b)q(ecause)0 1605 y(that)j(is)h(the)g(subtraction)g (function,)g(so)g(this)g(name)g(is)g(pro)o(vided)h(instead.)k(F)l(or)14 b(example,)i Fi(-x*y)e Fp(is)h(equiv)m(alen)o(t)0 1661 y(to)d Fi(negate)23 b(\(x*y\))o Fp(.)c(\(Pre\014x)12 b(min)o(us)h(has)f(the)g(same)g (syn)o(tactic)g(precedence)i(as)e(in\014x)h(min)o(us,)g(whic)o(h,)g(of)f (course,)0 1718 y(is)k(lo)o(w)o(er)f(than)g(that)f(of)h(m)o (ultiplication.\)])71 1801 y(Note)d(that)h Fi(Num)g Fp(do)q(es)g Fo(not)h Fp(pro)o(vide)f(a)g(division)j(op)q(erator;)c(t)o(w)o(o)g (di\013eren)o(t)i(kinds)g(of)f(division)i(op)q(erators)d(are)0 1857 y(pro)o(vided)k(in)g(t)o(w)o(o)e(non-o)o(v)o(erlapping)i(sub)q(classes)g (of)f Fi(Num)p Fp(:)71 1940 y(The)i(class)h Fi(Integral)e Fp(pro)o(vides)i (whole-n)o(um)o(b)q(er)h(division)g(and)f(remainder)g(op)q(erations,)f(as)g (w)o(ell)i(as)e(the)0 1996 y Fi(even)e Fp(and)h Fi(odd)g Fp(predicates.)23 b(The)16 b(standard)f(instances)i(of)e Fi(Integral)g Fp(are)h Fi(Integer)f Fp(\(un)o(b)q(ounded)i(or)e(math-)0 2053 y(ematical)20 b(in)o(tegers,)f(also)g(kno)o(wn)g(as)g(\\bign)o(ums"\))f(and)i Fi(Int)e Fp(\(b)q(ounded,)j(mac)o(hine)f(in)o(tegers,)f(with)h(a)e(range)0 2109 y(equiv)m(alen)o(t)i(to)f(at)f(least)h(29-bit)f(signed)i(binary\).)31 b(A)19 b(particular)g(Hask)o(ell)h(implemen)o(tation)g(migh)o(t)e(pro)o(vide) 0 2166 y(other)d(in)o(tegral)g(t)o(yp)q(es)g(in)g(addition)h(to)f(these.)20 b(Note)14 b(that)g Fi(Integral)g Fp(is)h(a)g(sub)q(class)h(of)e Fi(Real)p Fp(,)g(rather)h(than)f(of)0 2222 y Fi(Num)h Fp(directly;)h(this)g (means)f(that)f(there)h(is)h(no)f(attempt)g(to)f(pro)o(vide)i(Gaussian)f(in)o (tegers.)71 2305 y(All)23 b(other)e(n)o(umeric)i(t)o(yp)q(es)e(fall)i(in)g (the)f(class)g Fi(Fractional)n Fp(,)h(whic)o(h)g(pro)o(vides)f(the)g (ordinary)g(division)0 2361 y(op)q(erator)13 b Fi(\(/\))p Fp(.)19 b(The)c(further)e(sub)q(class)j Fi(Floating)d Fp(con)o(tains)h (trigonometric,)f(logarithmic,)i(and)f(exp)q(onen)o(tial)0 2418 y(functions.)71 2501 y(The)j Fi(RealFrac)g Fp(sub)q(class)h(of)g Fi(Fractional)e Fp(and)i Fi(Real)f Fp(pro)o(vides)h(a)f(function)h Fi(properFraction)n Fp(,)g(whic)o(h)0 2557 y(decomp)q(oses)e(a)f(n)o(um)o(b)q (er)h(in)o(to)f(its)h(whole)g(and)g(fractional)f(parts,)g(and)g(a)g (collection)j(of)d(functions)h(that)f(round)0 2614 y(to)g(in)o(tegral)g(v)m (alues)h(b)o(y)g(di\013ering)g(rules:)p eop %%Page: 34 34 bop 0 -40 a Fp(T-34)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")71 160 y Fi(properFraction)236 b(::)24 b(\(Fractional)e(a,)i (Integral)f(b\))g(=>)h(a)g(->)f(\(b,a\))71 216 y(truncate,)f(round,)71 272 y(floor,)h(ceiling:)213 b(::)24 b(\(Fractional)e(a,)i(Integral)f(b\))g (=>)h(a)g(->)f(b)71 453 y Fp(The)d Fi(RealFloat)f Fp(sub)q(class)j(of)e Fi(Floating)f Fp(and)i Fi(RealFrac)e Fp(pro)o(vides)i(some)f(sp)q(ecialized)j (functions)f(for)0 509 y(e\016cien)o(t)c(access)g(to)f(the)h(comp)q(onen)o (ts)g(of)f(a)g(\015oating-p)q(oin)o(t)i(n)o(um)o(b)q(er,)f(the)g Fo(exp)n(onent)f Fp(and)g Fo(signi\014c)n(and)p Fp(.)26 b(The)0 566 y(standard)15 b(t)o(yp)q(es)g Fi(Float)f Fp(and)i Fi(Double)e Fp(fall)i(in)g(class)g Fi(RealFloat)o Fp(.)0 782 y Fc(5.5.2)52 b(Constructed)17 b(Num)o(b)q(ers)0 924 y Fp(Of)h(the)g(standard)f(n)o(umeric) i(t)o(yp)q(es,)f Fi(Int)p Fp(,)g Fi(Integer)o Fp(,)g Fi(Float)o Fp(,)g(and)g Fi(Double)f Fp(are)h(primitiv)o(e.)29 b(The)18 b(others)f(are)0 981 y(made)e(from)g(these)g(b)o(y)g(t)o(yp)q(e)g (constructors:)71 1083 y Fi(Complex)e Fp(is)i(a)g(t)o(yp)q(e)f(constructor)g (that)g(mak)o(es)g(a)h(complex)g(t)o(yp)q(e)g(in)g(class)g Fi(Floating)f Fp(from)g(a)g Fi(RealFloat)0 1140 y Fp(t)o(yp)q(e:)71 1249 y Fi(data)23 b(\(RealFloat)f(a\))i(=>)g(Complex)e(a)i(=)g(a)g(:+)f(a)48 b(deriving)23 b(\(Eq,)g(Binary,)g(Text\))0 1358 y Fp(Notice)14 b(the)f(con)o(text)g Fi(\(RealFloat)23 b(a\))g(=>)p Fp(,)13 b(whic)o(h)i(restricts)e(the)g(argumen)o(t)g(t)o(yp)q(e;)g(th)o(us,)h(the)f (standard)g(com-)0 1414 y(plex)18 b(t)o(yp)q(es)g(are)f Fi(Complex)23 b(Float)17 b Fp(and)g Fi(Complex)23 b(Double)o Fp(.)k(W)l(e)17 b(can)h(also)f(see)h(from)f(the)g Fi(data)g Fp(declaration)0 1471 y(that)12 b(a)g(complex)i(n)o(um)o(b)q(er)e(is)h(written)g Fo(x)18 b Fi(:+)12 b Fo(y)t Fp(;)i(the)e(argumen)o(ts)g(are)g(the)h (cartesian)f(real)h(and)g(imaginary)g(parts,)0 1527 y(resp)q(ectiv)o(ely)l(.) 22 b(Since)16 b Fi(:+)f Fp(is)h(a)f(data)f(constructor,)g(w)o(e)h(can)h(use)f (it)h(in)g(pattern)e(matc)o(hing:)71 1636 y Fi(conjugate)356 b(::)24 b(\(RealFloat)e(a\))i(=>)g(Complex)e(a)i(->)g(Complex)f(a)71 1693 y(conjugate)f(\(x:+y\))190 b(=)48 b(x)24 b(:+)f(\(-y\))71 1873 y Fp(Similarly)l(,)15 b(the)f(t)o(yp)q(e)g(constructor)f Fi(Ratio)f Fp(mak)o(es)h(a)h(rational)f(t)o(yp)q(e)h(in)g(class)g Fi(RealFrac)f Fp(from)g(an)g(instance)0 1929 y(of)k Fi(Integral)o Fp(.)26 b(\()p Fi(Rational)16 b Fp(is)i(a)f(t)o(yp)q(e)h(synon)o(ym)f(for)g Fi(Ratio)23 b(Integer)o Fp(.\))j Fi(Ratio)o Fp(,)18 b(ho)o(w)o(ev)o(er,)f(is) h(an)f(abstract)0 1986 y(t)o(yp)q(e)h(constructor,)g(b)q(eing)h(de\014ned)h (in)f(the)f(Prelude)h(mo)q(dule)h Fi(PreludeRatio)n Fp(,)e(from)g(whic)o(h)h (it)f(is)h(exp)q(orted)0 2042 y(without)d(its)g(data)f(constructor;)g(th)o (us,)h(ratios)f(cannot)h(b)q(e)g(pattern-matc)o(hed.)22 b(Instead,)16 b(a)g(function)g(to)g(form)0 2099 y(a)f(ratio)g(from)f(t)o(w)o(o)g(in)o (tegers)h(is)h(pro)o(vided,)g(as)e(w)o(ell)j(as)d(comp)q(onen)o(t)i (extraction)f(functions:)71 2208 y Fi(\(\045\))500 b(::)24 b(\(Integral)f(a\))g(=>)h(a)f(->)h(a)g(->)f(Ratio)h(a)71 2264 y(numerator,)e(denominator)46 b(::)24 b(\(Integral)f(a\))g(=>)h(Ratio)f(a)h (->)f(a)71 2444 y Fp(Wh)o(y)17 b(the)g(di\013erence?)29 b(Complex)19 b(n)o(um)o(b)q(ers)e(in)i(cartesian)e(form)g(are)h(unique|there)h(are)e(no)h (non)o(trivial)0 2501 y(iden)o(tities)g(in)o(v)o(olving)g Fi(:+)p Fp(.)23 b(On)17 b(the)f(other)h(hand,)f(ratios)g(are)g(not)g(unique,)i(but)f (ha)o(v)o(e)f(a)g(canonical)h(\(reduced\))0 2557 y(form)h(that)f(the)i (implemen)o(tation)h(of)e(the)g(abstract)g(data)g(t)o(yp)q(e)g(m)o(ust)g (main)o(tain;)i(it)f(is)g(not)f(necessarily)i(the)0 2614 y(case,)14 b(for)h(instance,)g(that)f Fi(numerator)23 b(\(x\045y\))14 b Fp(is)h(equal)g(to)f Fi(x)p Fp(,)h(although)g(the)g(real)g(part)f(of)g Fi(x:+y)g Fp(is)i(alw)o(a)o(ys)e Fi(x)o Fp(.)p eop %%Page: 35 35 bop 0 -40 a Fj(5.5)45 b(Num)o(b)q(ers)1575 b Fp(T-35)0 105 y Fc(5.5.3)52 b(Numeric)17 b(Co)q(ercions)h(and)g(Ov)o(erloaded)f(Literals)0 269 y Fp(The)e(Standard)h(Prelude)g(pro)o(vides)g(sev)o(eral)f(o)o(v)o (erloaded)g(functions)h(that)f(serv)o(e)g(as)f(explicit)k(co)q(ercions:)71 378 y Fi(fromInteger)308 b(::)24 b(\(Num)f(a\))h(=>)f(Integer)g(->)h(a)71 435 y(fromRational)284 b(::)24 b(\(Fractional)e(a\))i(=>)f(Rational)g(->)h(a) 71 491 y(toInteger)356 b(::)24 b(\(Integral)f(a\))g(=>)h(a)f(->)h(Integer)71 548 y(toRational)332 b(::)24 b(\(RealFrac)f(a\))g(=>)h(a)f(->)h(Rational)71 604 y(fromIntegral)284 b(::)24 b(\(Integral)f(a,)g(Num)h(b\))f(=>)h(a)f(->)h (b)71 661 y(fromRealFrac)284 b(::)24 b(\(RealFrac)f(a,)g(Fractional)g(b\))g (=>)h(a)g(->)f(b)71 740 y(fromIntegral)284 b(=)48 b(fromInteger)22 b(.)i(toInteger)71 797 y(fromRealFrac)284 b(=)48 b(fromRational)22 b(.)i(toRational)71 992 y Fp(Tw)o(o)18 b(of)h(these)g(are)g(implicitly)k (used)c(to)g(pro)o(vide)h(o)o(v)o(erloaded)f(n)o(umeric)h(literals:)29 b(An)20 b(in)o(teger)g(n)o(umeral)0 1049 y(\(without)c(a)g(decimal)i(p)q(oin) o(t\))e(is)h(actually)g(equiv)m(alen)o(t)h(to)e(an)g(application)i(of)e Fi(fromInteger)f Fp(to)g(the)i(v)m(alue)g(of)0 1105 y(the)i(n)o(umeral)g(as)f (an)h Fi(Integer)o Fp(.)31 b(Similarly)l(,)21 b(a)e(\015oating)g(n)o(umeral)g (\(with)g(a)f(decimal)i(p)q(oin)o(t\))f(is)h(regarded)e(as)0 1162 y(an)e(application)h(of)e Fi(fromRational)g Fp(to)g(the)h(v)m(alue)h(of) e(the)h(n)o(umeral)g(as)f(a)h Fi(Rational)o Fp(.)21 b(Th)o(us,)16 b Fi(7)f Fp(has)h(the)g(t)o(yp)q(e)0 1218 y Fi(\(Num)23 b(a\))h(=>)f(a)p Fp(,)18 b(and)f Fi(7.3)g Fp(has)g(the)h(t)o(yp)q(e)f Fi(Fractional)23 b(a)g(=>)h(a)p Fp(.)i(This)18 b(means)f(that)g(w)o(e)g(can)g(use)h(n)o (umeric)0 1274 y(literals)e(in)g(generic)h(n)o(umeric)f(functions,)f(for)g (example:)71 1383 y Fi(halve)452 b(::)24 b(\(Fractional)e(a\))i(=>)f(a)h(->)g (a)71 1440 y(halve)f(x)405 b(=)48 b(x)24 b(*)f(0.5)0 1549 y Fp(This)16 b(rather)e(indirect)i(w)o(a)o(y)e(of)h(o)o(v)o(erloading)g(n)o (umerals)g(has)g(the)g(additional)i(adv)m(an)o(tage)d(that)g(the)h(metho)q(d) g(of)0 1605 y(in)o(terpreting)f(a)g(n)o(umeral)g(as)f(a)g(n)o(um)o(b)q(er)h (of)f(a)g(giv)o(en)i(t)o(yp)q(e)e(can)h(b)q(e)g(sp)q(eci\014ed)i(in)e(an)g Fi(Integral)e Fp(or)h Fi(Fractional)0 1662 y Fp(instance)j(declaration)g (\(since)g Fi(fromInteger)d Fp(and)i Fi(fromRational)f Fp(are)g(op)q(erators) g(of)h(those)g(classes,)g(resp)q(ec-)0 1718 y(tiv)o(ely\).)20 b(F)l(or)15 b(example,)h(the)f Fi(Num)g Fp(instance)h(of)e Fi(\(RealFloat)23 b(a\))g(=>)h(Complex)f(a)15 b Fp(con)o(tains)g(this)h (metho)q(d:)71 1830 y Fi(fromInteger)22 b(x)262 b(=)48 b(fromInteger)22 b(x)i(:+)g(0)0 1939 y Fp(This)15 b(sa)o(ys)f(that)g(a)h Fi(Complex)f Fp(instance)h(of)g Fi(fromInteger)e Fp(is)i(de\014ned)h(to)e(pro)q(duce)i(a)e (complex)i(n)o(um)o(b)q(er)f(whose)0 1995 y(real)h(part)e(is)i(supplied)i(b)o (y)d(an)g(appropriate)g Fi(RealFloat)f Fp(instance)j(of)d Fi(fromInteger)o Fp(.)20 b(In)c(this)g(manner,)f(ev)o(en)0 2052 y(user-de\014ned)i(n)o(umeric) f(t)o(yp)q(es)f(\(sa)o(y)l(,)f(quaternions\))i(can)f(mak)o(e)g(use)g(of)g(o)o (v)o(erloaded)g(n)o(umerals.)71 2170 y(As)g(another)g(example,)g(recall)i (our)d(\014rst)h(de\014nition)i(of)e Fi(succ)g Fp(from)f(Section)i(2:)71 2279 y Fi(succ)23 b(::)g(Int)h(->)g(Int)71 2335 y(succ)f(n)h(=)f(n+1)0 2444 y Fp(Ignoring)15 b(the)g(t)o(yp)q(e)f(signature,)g(the)h(most)f(general) h(t)o(yp)q(e)f(of)g Fi(succ)g Fp(is)h Fi(\(Num)23 b(a\))h(=>)g(a->a)o Fp(.)c(The)14 b(explicit)j(t)o(yp)q(e)0 2501 y(signature)h(is)g(legal,)h(ho)o (w)o(ev)o(er,)e(since)i(it)f(is)g Fo(mor)n(e)g(sp)n(e)n(ci\014c)e Fp(than)i(the)g(principal)i(t)o(yp)q(e)d(\(a)g(more)h(general)g(t)o(yp)q(e)0 2557 y(signature)e(w)o(ould)g(cause)g(a)f(static)g(error\).)20 b(The)c(t)o(yp)q(e)g(signature)g(has)f(the)h(e\013ect)f(of)h(restricting)g Fi(succ)o Fp('s)f(t)o(yp)q(e,)0 2614 y(and)g(in)h(this)g(case)f(w)o(ould)h (cause)f(something)h(lik)o(e)g Fi(succ)23 b(\(1::Float\))14 b Fp(to)h(b)q(e)h(ill-t)o(yp)q(ed.)p eop %%Page: 36 36 bop 0 -40 a Fp(T-36)771 b Fj(5)45 b(TYPE)15 b(CLASSES,)h(O)o(VERLO)o(ADING,)g (AND)f(\\OOP")0 105 y Fc(5.5.4)52 b(Default)18 b(Numeric)g(T)o(yp)q(es)0 216 y Fp(Consider)e(the)f(follo)o(wing)h(function)g(de\014nition:)71 325 y Fi(rms)500 b(::)24 b(\(Floating)f(a\))g(=>)h(a)f(->)h(a)g(->)f(a)71 381 y(rms)g(x)h(y)405 b(=)48 b(sqrt)23 b(\(\(x^2)g(+)h(y^2\))f(*)h(0.5\))0 493 y Fp(The)c(exp)q(onen)o(tiation)g(function)g Fi(\(^\))f Fp(\(one)g(of)g(three)g(di\013eren)o(t)h(standard)f(exp)q(onen)o(tiation)h (op)q(erators)f(with)0 549 y(di\013eren)o(t)13 b(t)o(ypings,)g(see)g Fn(x)p Fp(6.8.5\))e(has)h(the)h(t)o(yp)q(e)g Fi(\(Num)23 b(a,)h(Integral)e (b\))i(=>)g(a)f(->)h(b)g(->)f(a)p Fp(,)13 b(and)g(since)h Fi(2)e Fp(has)0 606 y(the)k(t)o(yp)q(e)f Fi(\(Num)24 b(a\))f(=>)h(a)p Fp(,)15 b(the)h(t)o(yp)q(e)g(of)f Fi(x^2)g Fp(is)h Fi(\(Num)23 b(a,)h(Integral)f(b\))g(=>)h(a)p Fp(.)d(This)16 b(is)g(a)g(problem;)g(there)0 662 y(is)g(no)g(w)o(a)o(y)e(to)i(resolv)o(e)f(the)h(o)o(v)o(erloading)g(asso) q(ciated)g(with)g(the)g(t)o(yp)q(e)f(v)m(ariable)i Fi(b)p Fp(,)f(since)g(it)g (is)h(in)f(the)g(con)o(text,)0 719 y(but)j(has)f(otherwise)h(v)m(anished)i (from)d(the)g(t)o(yp)q(e)h(expression.)31 b(Essen)o(tially)l(,)21 b(the)e(programmer)e(has)i(sp)q(eci\014ed)0 775 y(that)e Fi(x)h Fp(should)g(b)q(e)h(squared,)f(but)f(has)h(not)f(sp)q(eci\014ed)j(whether)e (it)g(should)h(b)q(e)f(squared)g(with)g(an)g Fi(Int)f Fp(or)g(an)0 832 y Fi(Integer)d Fp(v)m(alue)j(of)d(t)o(w)o(o.)19 b(Of)c(course,)g(w)o(e)g (can)g(\014x)h(this:)71 942 y Fi(rms)23 b(x)h(y)405 b(=)48 b(sqrt)23 b(\(\(x)h(^)f(\(2::Int\))g(+)h(y)g(^)f(\(2::Int\)\))g(*)h(0.5\))0 1051 y Fp(It's)15 b(ob)o(vious)g(that)g(this)g(sort)g(of)f(thing)i(will)h(so) q(on)e(gro)o(w)f(tiresome,)h(ho)o(w)o(ev)o(er.)71 1132 y(In)g(fact,)g(this)g (kind)i(of)d(o)o(v)o(erloading)i(am)o(biguit)o(y)f(is)h(not)f(restricted)g (to)g(n)o(um)o(b)q(ers:)71 1241 y Fi(show)23 b(\(read)g("xyz"\))0 1350 y Fp(As)d(what)f(t)o(yp)q(e)h(is)g(the)g(string)f(supp)q(osed)i(to)e(b)q (e)h(read?)35 b(This)20 b(is)g(more)f(serious)h(than)g(the)g(exp)q(onen)o (tiation)0 1407 y(am)o(biguit)o(y)l(,)14 b(b)q(ecause)h(there,)f(an)o(y)f Fi(Integral)g Fp(instance)i(will)g(do,)f(whereas)g(here,)g(v)o(ery)f (di\013eren)o(t)h(b)q(eha)o(vior)h(can)0 1463 y(b)q(e)h(exp)q(ected)g(dep)q (ending)i(on)d(what)f(instance)i(of)f Fi(Text)g Fp(is)h(used)f(to)g(resolv)o (e)g(the)h(am)o(biguit)o(y)l(.)71 1545 y(Because)h(of)f(the)g(di\013erence)i (b)q(et)o(w)o(een)f(the)f(n)o(umeric)i(and)e(general)h(cases)g(of)f(the)g(o)o (v)o(erloading)h(am)o(biguit)o(y)0 1601 y(problem,)24 b(Hask)o(ell)e(pro)o (vides)g(a)g(solution)g(that)f(is)h(restricted)g(to)f(n)o(um)o(b)q(ers:)33 b(Eac)o(h)22 b(mo)q(dule)h(ma)o(y)e(con)o(tain)0 1658 y(a)h Fo(default)h(de)n(clar)n(ation,)g Fp(consisting)g(of)f(the)g(k)o(eyw)o(ord)g Fi(default)f Fp(follo)o(w)o(ed)i(b)o(y)f(a)g(paren)o(thesized,)i(comma-)0 1714 y(separated)17 b(list)h(of)f(n)o(umeric)h(monot)o(yp)q(es)f(\(t)o(yp)q (es)h(with)f(no)h(v)m(ariables\).)27 b(When)18 b(an)f(am)o(bigous)g(t)o(yp)q (e)h(v)m(ariable)0 1770 y(is)h(disco)o(v)o(ered)f(\(suc)o(h)h(as)e Fi(b)p Fp(,)i(ab)q(o)o(v)o(e\),)f(if)g(at)g(least)g(one)g(of)g(its)h(classes) f(is)h(n)o(umeric)g(and)f(all)h(of)f(its)h(classes)f(are)0 1827 y(standard,)d(the)g(default)h(list)h(is)f(consulted,)g(and)f(the)h (\014rst)f(t)o(yp)q(e)g(from)g(the)h(list)g(that)f(will)i(satisfy)e(the)h (con)o(text)0 1883 y(of)g(the)h(t)o(yp)q(e)g(v)m(ariable)h(is)f(used.)25 b(F)l(or)16 b(example,)h(if)h(the)e(default)i(declaration)f Fi(default)23 b(\(Int,)g(Float\))16 b Fp(is)h(in)0 1940 y(e\013ect,)e(the)g (am)o(biguous)g(exp)q(onen)o(t)h(ab)q(o)o(v)o(e)f(will)h(b)q(e)g(resolv)o(ed) g(as)f(t)o(yp)q(e)g Fi(Int)p Fp(.)k(\(See)d Fn(x)p Fp(4.3.4)e(for)g(more)h (details.\))71 2021 y(The)f(\\default)h(default")g(is)g Fi(\(Int,)23 b(Double\))o Fp(,)15 b(but)f Fi(\(Integer,)23 b(Rational,)g(Double\))13 b Fp(ma)o(y)h(also)h(b)q(e)g(ap-)0 2078 y(propriate.)20 b(V)l(ery)15 b(cautious)h(programmers)e(ma)o(y)g(prefer)i Fi(default)22 b(\(\))p Fp(,)15 b(whic)o(h)h(pro)o(vides)g(no)f(defaults.)p eop %%Page: 37 37 bop 1857 -40 a Fp(T-37)0 105 y Fq(6)69 b(Mo)r(dules)0 237 y Fp(A)o(t)14 b(the)h(top)f(lev)o(el,)i(a)f(Hask)o(ell)g(program)f(consists)h (of)f(a)h(collection)h(of)f Fo(mo)n(dules)p Fp(.)k(A)c(mo)q(dule)h(in)g(Hask) o(ell)f(serv)o(es)0 294 y(the)g(dual)h(purp)q(ose)g(of)f(con)o(trolling)h (name-spaces)g(and)f(creating)g(abstract)g(data)f(t)o(yp)q(es.)71 379 y(The)19 b(top)f(lev)o(el)i(of)f(a)g(mo)q(dule)h(con)o(tains)f(an)o(y)f (of)h(the)g(v)m(arious)g(declarations)h(w)o(e)e(ha)o(v)o(e)h(discussed:)29 b(\014xit)o(y)0 435 y(declarations,)15 b(data)f(and)h(t)o(yp)q(e)g (declarations,)g(class)g(and)f(instance)i(declarations,)f(t)o(yp)q(e)g (signatures,)f(function)0 492 y(de\014nitions,)k(and)e(pattern)f(bindings.)25 b(Except)16 b(for)f(the)h(fact)g(that)f(\014xit)o(y)h(declarations)h(and)f (imp)q(ort)g(declara-)0 548 y(tions)i(\(to)f(b)q(e)i(describ)q(ed)h (shortly\))e(m)o(ust)f(app)q(ear)h(\014rst,)g(the)h(declarations)f(ma)o(y)g (app)q(ear)g(in)h(an)o(y)e(order)h(\(the)0 605 y(top-lev)o(el)e(scop)q(e)g (is)g(m)o(utually)g(recursiv)o(e\).)71 690 y(Hask)o(ell's)d(mo)q(dule)g (design)h(is)f(relativ)o(ely)g(conserv)m(ativ)o(e:)19 b(The)13 b(namespace)g(of)f(mo)q(dules)i(is)f(completely)h(\015at,)0 746 y(and)h(mo)q(dules)i(are)d(in)j(no)e(w)o(a)o(y)f(\\\014rst-class.")19 b(Mo)q(dule)d(names)g(are)e(alphan)o(umeric)j(and)e(m)o(ust)g(b)q(egin)i (with)e(an)0 803 y(upp)q(ercase)g(letter.)20 b(There)14 b(is)h(no)f(formal)f (connection)i(b)q(et)o(w)o(een)g(a)e(Hask)o(ell)i(mo)q(dule)h(and)e(the)g (\014le)h(system)f(that)0 859 y(w)o(ould)i(\(t)o(ypically\))h(supp)q(ort)f (it.)22 b(In)17 b(particular,)f(there)g(is)h(no)f(connection)h(b)q(et)o(w)o (een)f(mo)q(dule)h(names)f(and)g(\014le)0 916 y(names,)g(and)g(more)g(than)g (one)g(mo)q(dule)h(could)g(conceiv)m(ably)i(reside)e(in)g(a)f(single)h (\014le)g(\(one)f(mo)q(dule)h(ma)o(y)f(ev)o(en)0 972 y(span)g(sev)o(eral)f (\014les\).)22 b(Of)15 b(course,)h(a)f(particular)h(implemen)o(tation)h(will) g(most)e(lik)o(ely)i(adopt)e(con)o(v)o(en)o(tions)h(that)0 1029 y(mak)o(e)f(the)g(connection)h(b)q(et)o(w)o(een)g(mo)q(dules)g(and)f (\014les)i(more)d(stringen)o(t.)71 1114 y(T)l(ec)o(hnically)h(sp)q(eaking,)f (a)f(mo)q(dule)h(is)g(really)g(just)f(one)g(big)h(declaration)g(whic)o(h)g(b) q(egins)g(with)g(the)f(k)o(eyw)o(ord)0 1170 y Fi(module)o Fp(;)i(here's)g(an) g(example)h(for)f(a)g(mo)q(dule)h(whose)f(name)g(is)h Fi(Tree)p Fp(:)71 1279 y Fi(module)23 b(Tree)g(\()h(Tree\(Leaf,Branch\),)d(fringe)i(\)) h(where)71 1359 y(data)f(Tree)g(a)382 b(=)24 b(Leaf)f(a)h(|)f(Branch)g (\(Tree)h(a\))f(\(Tree)g(a\))71 1439 y(fringe)g(::)g(Tree)h(a)f(->)h([a])71 1495 y(fringe)f(\(Leaf)g(x\))286 b(=)24 b([x])71 1551 y(fringe)f(\(Branch)g (left)g(right\))g(=)h(fringe)f(left)g(++)h(fringe)f(right)0 1661 y Fp(The)14 b(t)o(yp)q(e)g Fi(Tree)f Fp(and)h(the)g(function)h Fi(fringe)e Fp(should)i(b)q(e)g(familiar;)f(they)g(w)o(ere)g(giv)o(en)g(as)g (examples)g(in)h(Section)0 1717 y(2.3.)29 b([Because)19 b(of)f(the)h Fi(where)f Fp(k)o(eyw)o(ord,)g(la)o(y)o(out)g(is)h(activ)o(e)g(at)e(the)i (top)f(lev)o(el)i(of)e(a)h(mo)q(dule,)h(and)e(th)o(us)h(the)0 1773 y(declarations)f(m)o(ust)e(all)i(line)g(up)f(in)h(the)f(same)f(column)i (\(t)o(ypically)g(the)f(\014rst\).)24 b(Also)17 b(note)g(that)f(the)h(mo)q (dule)0 1830 y(name)e(is)h(the)f(same)g(as)g(that)f(of)h(the)g(t)o(yp)q(e;)g (this)h(is)g(allo)o(w)o(ed.])71 1915 y(This)e(mo)q(dule)h(explicitly)i Fo(exp)n(orts)d Fi(Tree)o Fp(,)g Fi(Leaf)o Fp(,)g Fi(Branch)o Fp(,)g(and)g Fi(fringe)o Fp(.)20 b(If)14 b(the)g(exp)q(ort)g(list)g(follo)o (wing)h(the)0 1972 y Fi(module)10 b Fp(k)o(eyw)o(ord)g(is)h(omitted,)g Fo(al)r(l)g Fp(of)f(the)h(names)g(b)q(ound)h(at)e(the)h(top)f(lev)o(el)i(of)f (the)f(mo)q(dule)i(w)o(ould)g(b)q(e)f(exp)q(orted.)0 2028 y(\(In)h(the)h(ab)q (o)o(v)o(e)e(example)i(ev)o(erything)g(is)f(explicitly)j(exp)q(orted,)e(so)e (the)i(e\013ect)e(w)o(ould)i(b)q(e)g(the)f(same.\))18 b(Note)12 b(that)0 2084 y(the)k(name)f(of)g(a)h(t)o(yp)q(e)f(and)h(its)g(constructors)f (m)o(ust)g(b)q(e)h(group)q(ed)g(together,)f(as)g(in)h Fi(Tree\(Leaf,Branch\)) n Fp(.)21 b(As)0 2141 y(short-hand,)15 b(w)o(e)g(could)h(also)f(write)g Fi(Tree\(..\))f Fp(\(exp)q(orting)i(a)f(subset)g(of)g(the)g(constructors)f (is)i(not)f(allo)o(w)o(ed\).)71 2226 y(The)g Fi(Tree)g Fp(mo)q(dule)h(ma)o(y) e(no)o(w)h(b)q(e)h Fo(imp)n(orte)n(d)g Fp(in)o(to)f(some)g(other)f(mo)q (dule:)71 2335 y Fi(module)23 b(Main)g(\(main\))g(where)71 2392 y(import)g(Tree)g(\()h(Tree\(Leaf,Branch\),)d(fringe)i(\))71 2448 y(main)g(::)g(Dialogue)71 2504 y(main)g(=)h(print)f(\(fringe)g(\(Branch) g(\(Leaf)g(1\))g(\(Leaf)h(2\)\)\))0 2614 y Fp(The)16 b(v)m(arious)g(items)g (b)q(eing)g(imp)q(orted)g(in)o(to)g(and)g(exp)q(orted)g(out)f(of)g(a)g(mo)q (dule)i(are)e(called)i Fo(entities)p Fp(.)j(Note)15 b(the)p eop %%Page: 38 38 bop 0 -40 a Fp(T-38)1557 b Fj(6)46 b(MODULES)0 105 y Fp(explicit)21 b(imp)q(ort)d(list)h(in)h(the)e(imp)q(ort)h(declaration;)h(omitting)f(it)g(w) o(ould)g(cause)f(all)i(en)o(tities)f(exp)q(orted)g(from)0 162 y Fi(Tree)c Fp(to)f(b)q(e)i(imp)q(orted.)71 244 y(The)c(en)o(tit)o(y)h Fi(main)e Fp(\(and)i(its)f(t)o(yping\))h(and)f(the)h(mo)q(dule)g(name)g Fi(Main)o Fp(,)g(in)g(the)g(ab)q(o)o(v)o(e)f(example,)h(ha)o(v)o(e)f(sp)q (ecial)0 300 y(signi\014cance,)17 b(as)e(sp)q(eci\014ed)i(in)f(the)f(Rep)q (ort:)71 383 y(\\A)d(Hask)o(ell)i Fo(pr)n(o)n(gr)n(am)g Fp(is)f(a)g (collection)i(of)d(mo)q(dules,)j(one)e(of)f(whic)o(h,)i(b)o(y)f(con)o(v)o(en) o(tion,)h(m)o(ust)e(b)q(e)i(called)h Fi(Main)0 439 y Fp(and)j(m)o(ust)f(exp)q (ort)g(the)h(v)m(alue)h Fi(main)o Fp(.)27 b(The)18 b Fo(value)g Fp(of)f(the)h(program)e(is)i(the)g(v)m(alue)h(of)e(the)h(iden)o(ti\014er)h Fi(main)e Fp(in)0 496 y(mo)q(dule)f Fi(Main)p Fp(,)f(and)g Fi(main)g Fp(m)o(ust)f(ha)o(v)o(e)h(t)o(yp)q(e)g Fi(Dialogue)o Fp(.")71 578 y(\(The)e(t)o(yp)q(e)g Fi(Dialogue)f Fp(relates)h(to)g(I/O,)g (and)h(is)f(discussed)i(in)f(Section)g(8.\))19 b(Th)o(us)13 b(the)g(ab)q(o)o(v)o(e)g(t)o(w)o(o)f(mo)q(dules)0 634 y(together)i (constitute)i(a)f(v)m(alid)i(Hask)o(ell)f(program.)0 784 y Fg(6.1)56 b(Original)17 b(Names)h(and)h(Renaming)0 896 y Fp(Abstractly)d (asso)q(ciated)h(with)g(ev)o(ery)f(en)o(tit)o(y)g(is)h(its)g Fo(original)g(name)p Fp(|a)f(pair)h(consisting)g(of)f(the)g(name)h(of)f(the)0 953 y(en)o(tit)o(y)d(and)h(the)f(name)g(of)g(the)h(mo)q(dule)g(in)h(whic)o(h) f(it)f(w)o(as)g(originally)i(de\014ned.)20 b(This)14 b(concept)g(is)g(useful) g(in)h(that)0 1009 y(it)f(allo)o(ws)g(an)f(en)o(tit)o(y)h(with)g(the)g(same)f (name)h(to)f(b)q(e)h(imp)q(orted)g(from)f(a)g(v)m(ariet)o(y)h(of)f (di\013eren)o(t)h(mo)q(dules,)h(without)0 1066 y(con\015ict,)h(as)f(long)g (as)g(the)g(original)h(name)g(is)f(the)h(same.)71 1148 y(En)o(tities)f(b)q (eing)i(imp)q(orted)f(can)f(also)g(b)q(e)h Fo(r)n(ename)n(d)p Fp(;)e(for)h(example:)71 1257 y Fi(import)23 b(Tree)g(\()h (Tree\(Leaf,Branch\),)d(fringe)i(\))238 1313 y(renaming)f(\(Leaf)i(to)f (Root,)g(Branch)g(to)h(Twig\))0 1541 y Fg(6.2)56 b(In)n(terfaces)18 b(and)h(Impleme)o(n)n(tations)0 1653 y Fp(The)d(mo)q(dules)h Fi(Tree)e Fp(and)g Fi(Main)g Fp(sho)o(wn)h(ab)q(o)o(v)o(e)f(are)g(in)i (actualit)o(y)f(mo)q(dule)g Fo(implementations)p Fp(|they)g(con)o(tain)0 1709 y(all)j(of)e(the)h(Hask)o(ell)g(co)q(de)g(to)g(completely)h(de\014ne)f (a)g(mo)q(dule.)28 b(The)18 b(information)g(passed)g(b)q(et)o(w)o(een)g(mo)q (dules)0 1766 y(during)f(exp)q(ort)e(and)h(imp)q(ort,)g(ho)o(w)o(ev)o(er,)f (is)h(more)f(abstract,)g(and)h(is)g(captured)g(formally)g(in)h(a)e(mo)q(dule) i Fo(inter-)0 1822 y(fac)n(e)p Fp(.)i(The)c(in)o(terface)g(for)f(a)g(mo)q (dule)i Fi(M)e Fp(con)o(tains)h(all)g(of)f(the)h(information)f(ab)q(out)h (the)f(en)o(tities)i(exp)q(orted)f(from)0 1879 y Fi(M)h Fp(that)f(is)i (needed)h(to)d(ensure)i(prop)q(er)f(t)o(yping)h(of)e(some)h(other)g(mo)q (dule)h Fi(N)f Fp(that)g(ma)o(y)f(imp)q(ort)i Fi(M)p Fp(.)22 b(The)17 b(prop)q(er)0 1935 y(in)o(terfaces)e(for)g(the)g(mo)q(dules)i Fi(Tree)d Fp(and)i Fi(Main)e Fp(are:)71 2035 y Fi(interface)22 b(Tree)i(\()f(Tree\(Leaf,Branch\),)f(fringe)h(\))g(where)71 2092 y(data)g(Tree)g(a)h(=)g(Leaf)f(a)h(|)f(Branch)g(\(Tree)h(a\))f(\(Tree)g (a\))71 2148 y(fringe)g(::)g(Tree)h(a)f(->)h([a])71 2228 y(interface)e(Main)i (\(main\))f(where)71 2284 y(import)g(Tree)g(\()h(Tree\(Leaf,Branch\),)d (fringe)i(\))71 2341 y(main)g(::)g(Dialogue)71 2501 y Fp(Normally)12 b(the)f(user)h(need)g(not)f(b)q(e)i(concerned)f(ab)q(out)g(mo)q(dule)g(in)o (terfaces,)g(since)h(they)f(are)f(usually)i(deriv)o(ed)0 2557 y(automatically)k(from)f(the)h(mo)q(dule)h(implemen)o(tation.)27 b(On)17 b(the)g(other)f(hand,)i(it)f(is)g(not)g(un)o(usual)h(to)e(w)o(an)o(t) g(to)0 2614 y(statically)f(debug)h(a)e(mo)q(dule)i(implemen)o(tation)g(that)e (imp)q(orts)h(some)f(other)g(mo)q(dule)i(whose)f(implemen)o(tation)p eop %%Page: 39 39 bop 0 -40 a Fj(6.3)45 b(Abstract)14 b(Data)g(T)o(yp)q(es)1332 b Fp(T-39)0 105 y(do)q(es)21 b(not)g(exist)g(y)o(et;)i(b)q(eing)f(able)g(to)e (explicitly)k(write)d(the)g(in)o(terface)g(for)g(this)g(imp)q(orted)g(mo)q (dule)i(w)o(ould)0 162 y(p)q(ermit)f(this.)41 b(Indeed,)24 b(in)o(terfaces)e(supp)q(ort)g(top-do)o(wn,)h(successiv)o(e)g(re\014nemen)o (t,)g(soft)o(w)o(are)d(dev)o(elopmen)o(t)0 218 y(metho)q(dologies,)c(in)g (whic)o(h)g Fo(al)r(l)f Fp(in)o(terfaces)g(are)g(ideally)i(written)e Fo(\014rst)p Fp(.)0 493 y Fg(6.3)56 b(Abstract)19 b(Data)f(T)n(yp)r(es)0 661 y Fp(Aside)j(from)f(con)o(trolling)h(namespaces,)g(mo)q(dules)g(pro)o (vide)g(the)f(only)h(w)o(a)o(y)e(to)g(build)j(abstract)d(data)h(t)o(yp)q(es)0 717 y(\(ADTs\))c(in)i(Hask)o(ell.)27 b(F)l(or)17 b(example,)h(the)g(c)o (haracteristic)f(feature)g(of)g(an)g(ADT)g(is)h(that)f(the)g Fo(r)n(epr)n(esentation)0 774 y(typ)n(e)i Fp(is)h Fo(hidden)p Fp(;)h(all)f(op)q(erations)f(on)g(the)g(ADT)g(are)g(done)h(at)e(an)h (abstract)f(lev)o(el)j(whic)o(h)f(do)q(es)g(not)e(dep)q(end)0 830 y(on)f(the)h(represen)o(tation.)26 b(F)l(or)16 b(example,)j(although)e (the)g Fi(Tree)g Fp(t)o(yp)q(e)g(is)h(simple)h(enough)f(that)e(w)o(e)h(migh)o (t)g(not)0 886 y(normally)e(mak)o(e)g(it)g(abstract,)e(a)h(suitable)i(ADT)f (for)f(it)h(migh)o(t)g(include)i(the)e(follo)o(wing)g(op)q(erations,)g(whic)o (h)g(w)o(e)0 943 y(sp)q(ecify)i(in)f(the)f(form)f(of)h(an)g(in)o(terface:)71 1052 y Fi(interface)22 b(TreeADT)h(\(Tree,)g(leaf,)g(branch,)g(cell,)524 1108 y(left,)g(right,)g(isLeaf,)g(isBranch\))g(where)71 1165 y(data)g(Tree)g(a)71 1221 y(leaf)476 b(::)24 b(a)g(->)f(Tree)h(a)71 1278 y(branch)428 b(::)24 b(Tree)f(a)h(->)g(Tree)f(a)h(->)f(Tree)g(a)71 1334 y(cell)476 b(::)24 b(Tree)f(a)h(->)g(a)71 1391 y(left,)f(right)309 b(::)24 b(Tree)f(a)h(->)g(Tree)f(a)71 1447 y(isLeaf)428 b(::)24 b(Tree)f(a)h(->)g(Bool)0 1556 y Fp(A)15 b(mo)q(dule)i(implemen)o(tation)f (supp)q(orting)g(this)g(is:)71 1665 y Fi(module)23 b(TreeADT)g(\(Tree,)g (leaf,)g(branch,)g(cell,)452 1722 y(left,)h(right,)f(isLeaf\))g(where)71 1801 y(data)g(Tree)g(a)310 b(=)24 b(Leaf)f(a)h(|)g(Branch)f(\(Tree)g(a\))h (\(Tree)f(a\))71 1881 y(leaf)476 b(=)24 b(Leaf)71 1937 y(branch)428 b(=)24 b(Branch)71 1994 y(cell)47 b(\(Leaf)23 b(a\))238 b(=)24 b(a)71 2050 y(left)47 b(\(Branch)23 b(l)g(r\))143 b(=)24 b(l)71 2107 y(right)f(\(Branch)g(l)g(r\))143 b(=)24 b(r)71 2163 y(isLeaf)70 b(\(Leaf)24 b(_\))166 b(=)24 b(True)71 2220 y(isLeaf)70 b(_)334 b(=)24 b(False)0 2331 y Fp(Note)d(in)h(the)g(exp)q(ort)f(list)i(that)d(the)i (t)o(yp)q(e)f(name)h Fi(Tree)f Fp(app)q(ears)g(alone)h(\(i.e.)f(without)h (its)g(constructors\);)0 2388 y(similarly)l(,)e(in)f(the)e(in)o(terface)h (the)g Fi(data)f Fp(declaration)i(for)e Fi(Tree)g Fp(do)q(es)h(not)f(include) k(the)c(constructors.)27 b(Th)o(us)0 2444 y Fi(Leaf)17 b Fp(and)h Fi(Branch)f Fp(are)h(not)f(exp)q(orted,)h(and)g(the)g(only)h(w)o(a)o(y)d(to)h (build)j(or)e(tak)o(e)f(apart)g(trees)g(outside)i(of)e(the)0 2501 y(mo)q(dule)f(is)f(b)o(y)g(using)h(the)f(v)m(arious)g(\(abstract\))e(op) q(erations.)20 b(Of)15 b(course,)g(the)g(adv)m(an)o(tage)f(of)h(this)g (information)0 2557 y(hiding)20 b(is)e(that)f(at)h(a)g(later)g(time)g(w)o(e)g (could)h Fo(change)e Fp(the)h(represen)o(tation)g(t)o(yp)q(e)g(without)g (a\013ecting)g(users)g(of)0 2614 y(the)d(t)o(yp)q(e.)p eop %%Page: 40 40 bop 0 -40 a Fp(T-40)1368 b Fj(7)45 b(TYPING)15 b(PITF)-5 b(ALLS)0 105 y Fg(6.4)56 b(Rules,)17 b(Rules,)g(and)j(More)e(Rules)0 227 y Fp(Although)f(Hask)o(ell's)h(mo)q(dule)g(system)e(is)i(relativ)o(ely)g (conserv)m(ativ)o(e,)f(there)g(are)g(man)o(y)f(rules)i(concerning)g(the)0 283 y(imp)q(ort)g(and)g(exp)q(ort)g(of)g(v)m(alues.)29 b(Most)17 b(of)g(these)h(are)g(ob)o(vious|for)g(instance,)h(it)f(is)h(illegal)h(to)d (imp)q(ort)h(t)o(w)o(o)0 340 y(di\013eren)o(t)f(en)o(tities)h(ha)o(ving)f (the)f(same)h(name)f(in)o(to)h(the)g(same)f(scop)q(e.)25 b(Other)17 b(rules)h(are)e(not)h(so)f(ob)o(vious|for)0 396 y(example,)f(an)e Fi(instance)g Fp(declaration)i(can)f(only)g(app)q(ear)g(in)h(the)f(mo)q(dule) g(in)h(whic)o(h)g(the)f(corresp)q(onding)h Fi(data)0 453 y Fp(or)g Fi(class)f Fp(declaration)i(app)q(ears.)k(The)c(reader)f(should)h (read)f(the)g(Rep)q(ort)h(for)e(details)j(\()p Fn(x)o Fp(5\).)0 646 y Fq(7)69 b(T)n(yping)23 b(Pitfalls)0 783 y Fp(This)c(short)e(section)i (giv)o(e)f(an)g(in)o(tuitiv)o(e)i(description)f(of)f(a)g(few)g(common)g (problems)g(that)g(no)o(vices)h(run)f(in)o(to)0 840 y(using)e(Hask)o(ell's)g (t)o(yp)q(e)f(system.)0 1011 y Fg(7.1)56 b(Let-Bound)17 b(P)n(olymorphism)0 1133 y Fp(An)o(y)i(language)h(using)g(the)f(Hindley-Milne)q(r)j(t)o(yp)q(e)d (system)g(has)g(what)f(is)i(called)h Fo(let-b)n(ound)f(p)n(olymorphism)p Fp(,)0 1189 y(b)q(ecause)g(iden)o(ti\014ers)g(not)e(b)q(ound)i(using)g(a)e Fi(let)g Fp(or)h Fi(where)f Fp(clause)h(\(or)f(at)g(the)h(top)g(lev)o(el)h (of)e(a)h(mo)q(dule\))g(are)0 1246 y(limited)14 b(with)e(resp)q(ect)h(to)e (their)h(p)q(olymorphism.)20 b(In)13 b(particular,)g(a)f Fo(lamb)n(da-b)n (ound)g Fp(function)h(\(i.e.,)f(one)g(passed)0 1302 y(as)k(argumen)o(t)g(to)f (another)h(function\))h(cannot)f(b)q(e)h(instan)o(tiated)g(in)g(t)o(w)o(o)e (di\013eren)o(t)i(w)o(a)o(ys.)22 b(F)l(or)15 b(example,)j(this)0 1359 y(program)c(is)i(illegal:)71 1468 y Fi(let)23 b(f)h(g)47 b(=)h(\(g)24 b([],)f(g)h('a'\))548 b(--)24 b(ill-typed)e(expression)71 1524 y(in)h(f)h(\(\\x->x\))0 1633 y Fp(b)q(ecause)19 b Fi(g)p Fp(,)f(b)q(ound)h(to)e(a)h(lam)o(b)q(da)g(abstraction)g(whose)g(principal)i (t)o(yp)q(e)e(is)h Fi(a->a)o Fp(,)f(is)h(used)f(within)i Fi(f)d Fp(in)i(t)o(w)o(o)0 1690 y(di\013eren)o(t)c(w)o(a)o(ys:)k(once)d(with)f(t)o (yp)q(e)h Fi([a]->[a])n Fp(,)f(and)h(once)f(with)h(t)o(yp)q(e)f Fi(Char->Char)o Fp(.)0 1861 y Fg(7.2)56 b(Numeric)16 b(Ov)n(erloading)0 1983 y Fp(It)f(is)g(easy)g(to)f(forget)g(at)g(times)h(that)g(n)o(umerals)g (are)f Fo(overlo)n(ade)n(d,)h Fp(and)g Fo(not)h(implicitly)g(c)n(o)n(er)n(c)n (e)n(d)d Fp(to)i(the)f(v)m(arious)0 2040 y(n)o(umeric)k(t)o(yp)q(es,)g(as)e (in)j(man)o(y)d(other)h(languages.)26 b(More)17 b(general)h(n)o(umeric)g (expressions)g(sometimes)f(cannot)0 2096 y(b)q(e)f(quite)g(so)f(generic.)20 b(A)c(common)e(n)o(umeric)j(t)o(yping)e(error)f(is)i(something)g(lik)o(e)g (the)f(follo)o(wing:)71 2205 y Fi(average)22 b(xs)334 b(=)48 b(sum)23 b(xs)h(/)g(length)f(xs)262 b(--)24 b(Wrong!)0 2314 y(\(/\))c Fp(requires)h(fractional)f(argumen)o(ts,)g(but)h Fi(length)o Fp('s)f(result)g(is)h(an)f Fi(Int)p Fp(.)35 b(The)20 b(t)o(yp)q(e)h(mismatc)o(h)f(m)o(ust)f(b)q(e)0 2371 y(corrected)c(with)h(an)f (explicit)i(co)q(ercion:)71 2480 y Fi(average)404 b(::)24 b(\(Fractional)e (a\))i(=>)f([a])h(->)f(a)71 2536 y(average)f(xs)334 b(=)48 b(sum)23 b(xs)h(/)g(fromIntegral)e(\(length)h(xs\))p eop %%Page: 41 41 bop 0 -40 a Fj(7.3)45 b(The)15 b(Monomorphism)g(Restriction)1118 b Fp(T-41)0 105 y Fg(7.3)56 b(The)18 b(Monomorphism)e(Restriction)0 213 y Fp(The)e(Hask)o(ell)h(t)o(yp)q(e)g(system)e(con)o(tains)i(a)f (restriction)g(related)h(to)e(t)o(yp)q(e)i(classes)f(that)g(is)h(not)e(found) i(in)g(ordinary)0 269 y(Hindley-Milne)q(r)23 b(t)o(yp)q(e)d(systems:)29 b(the)20 b Fo(monomorphism)i(r)n(estriction)p Fp(.)34 b(The)21 b(reason)f(for)f(this)i(restriction)f(is)0 326 y(related)c(to)e(a)h(subtle)h (t)o(yp)q(e)f(am)o(biguit)o(y)g(and)h(is)f(explained)j(in)d(full)i(detail)f (in)g(the)f(Rep)q(ort)h(\()p Fn(x)p Fp(4.5.4\).)i(A)d(simpler)0 382 y(explanation)h(follo)o(ws:)71 461 y(The)g(monomorphism)f(restriction)i (sa)o(ys)e(that)g(an)o(y)g(iden)o(ti\014er)j(b)q(ound)e(b)o(y)g(a)g(pattern)f (binding)j(\(whic)o(h)e(in-)0 517 y(cludes)e(bindings)g(to)e(a)g(single)i (iden)o(ti\014er\),)g(and)e(ha)o(ving)h(no)f(explicit)j(t)o(yp)q(e)e (signature,)f(m)o(ust)g(b)q(e)h Fo(monomorphic)p Fp(.)0 574 y(An)h(iden)o(ti\014er)h(is)f(monomorphic)g(if)f(is)h(either)h(not)e(o)o(v)o (erloaded,)g(or)g(is)h(o)o(v)o(erloaded)f(but)h(is)g(used)g(in)g(at)f(most)g (one)0 630 y(sp)q(eci\014c)k(o)o(v)o(erloading)e(and)h(is)f(not)g(exp)q (orted.)71 709 y(Violations)e(of)e(this)i(restriction)g(result)f(in)h(a)f (static)g(t)o(yp)q(e)h(error.)18 b(The)12 b(simplest)h(w)o(a)o(y)f(to)f(a)o (v)o(oid)h(the)g(problem)0 765 y(is)18 b(to)g(pro)o(vide)g(an)g(explicit)i(t) o(yp)q(e)e(signature.)28 b(Note)17 b(that)g Fo(any)h Fp(t)o(yp)q(e)g (signature)g(will)h(do)f(\(as)f(long)h(it)h(is)f(t)o(yp)q(e)0 822 y(correct\).)71 900 y(A)12 b(common)h(violation)g(of)g(the)f(restriction) i(happ)q(ens)f(with)g(functions)h(de\014ned)g(in)f(a)g(higher-order)g (manner,)0 957 y(as)i(in)h(this)f(de\014nition)i(of)e Fi(sum)g Fp(from)f(the)i(Standard)f(Prelude:)71 1057 y Fi(sum)500 b(=)48 b(foldl)23 b(\(+\))h(0)0 1166 y Fp(As)15 b(is,)h(this)f(w)o(ould)h(cause)f(a) g(static)g(t)o(yp)q(e)g(error.)k(W)l(e)d(can)f(\014x)h(the)f(problem)h(b)o(y) f(adding)h(the)f(t)o(yp)q(e)g(signature:)71 1275 y Fi(sum)500 b(::)24 b(\(Num)f(a\))h(=>)f([a])h(->)f(a)0 1384 y Fp(Also)16 b(note)f(that)f(this)i(problem)g(w)o(ould)f(not)g(ha)o(v)o(e)g(arisen)g(if)h (w)o(e)f(had)g(written:)71 1493 y Fi(sum)23 b(xs)429 b(=)48 b(foldl)23 b(\(+\))h(0)f(xs)0 1602 y Fp(b)q(ecause)16 b(the)f(restriction)h (only)g(applies)h(to)d(pattern)h(bindings.)0 1766 y Fq(8)69 b(Input/Output)0 1890 y Fp(The)17 b(I/O)h(system)e(in)i(Hask)o(ell)g(is)g (purely)g(functional,)g(y)o(et)f(has)g(all)h(the)f(expressiv)o(e)h(p)q(o)o(w) o(er)f(of)f(that)h(found)g(in)0 1946 y(con)o(v)o(en)o(tional)h(programming)f (languages.)27 b(T)l(o)18 b(ac)o(hiev)o(e)g(this,)g(Hask)o(ell)g(relies)h (critically)h(on)e(lazy)g(ev)m(aluation)0 2002 y(and)d(higher-order)h (functions,)g(the)f(k)o(ey)g(building)j(blo)q(c)o(ks)e(of)f(an)o(y)g (functional)h(program.)j(\()p Fn(x)p Fp(7\))71 2081 y(The)13 b(Rep)q(ort)h(describ)q(es)i(t)o(w)o(o)c(equiv)m(alen)o(t)j(w)o(a)o(ys)e(to)g (do)h(I/O)g(in)g(Hask)o(ell:)20 b(the)14 b Fo(str)n(e)n(am-b)n(ase)n(d)e Fp(approac)o(h)i(and)0 2137 y(the)f Fo(c)n(ontinuation-b)n(ase)n(d)e Fp(approac)o(h.)19 b(The)13 b(former)f(is)h(probably)g(easier)g(to)f(explain) j(conceptually)l(,)f(and)f(indeed)0 2194 y(the)19 b(latter)f(is)h(de\014ned)h (in)f(terms)f(of)g(the)h(former)f(in)h(the)g(Rep)q(ort.)30 b(Ho)o(w)o(ev)o(er,)18 b(for)g(practical)h(programming,)0 2250 y(the)g(latter)f(\(con)o(tin)o(uation-based\))h(approac)o(h)g(is)g(the)g (preferred)g(metho)q(dology)l(,)g(and)g(that)f(is)i(what)e(w)o(e)g(will)0 2307 y(concen)o(trate)d(on)g(in)h(this)g(section.)k(\()p Fn(x)p Fp(7.5\))0 2449 y Fg(8.1)56 b(In)n(tro)r(duction)18 b(to)g(Con)n(tin)n (uations)0 2557 y Fp(T)l(o)13 b(understand)g(this)h(metho)q(dology)l(,)f(it)g (is)g(helpful)i(to)e(ha)o(v)o(e)f(some)h(understanding)h(of)e(the)h(notion)h (of)e(a)h Fo(c)n(ontin-)0 2614 y(uation)p Fp(.)20 b(A)13 b(con)o(tin)o (uation)h(is)f(basically)i(a)e(\(p)q(ossibly)i(n)o(ullary\))f Fo(function)e Fp(that)h(maps)g(an)g(\\in)o(termediate)h(v)m(alue")p eop %%Page: 42 42 bop 0 -40 a Fp(T-42)1417 b Fj(8)45 b(INPUT/OUTPUT)0 105 y Fp(\(p)q(ossibly)20 b(empt)o(y\))e(to)g(\\the)g(rest)g(of)h(the)f(program.")29 b(In)19 b(this)g(w)o(a)o(y)l(,)g(con)o(tin)o(uations)g(are)f(used)h(to)f (explicitly)0 162 y(manage)d(\\\015o)o(w)h(of)f(con)o(trol,")h(and)g(th)o(us) g(w)o(e)f(tend)i(to)e(de\014ne)i(functions)g(that,)e(instead)i(of)e (returning)i(with)f(an)0 218 y(answ)o(er,)g(will)j(apply)e(a)f(con)o(tin)o (uation)i(\(passed)e(in)i(as)e(an)h(argumen)o(t\))e(to)h(the)h(answ)o(er.)24 b(Because)17 b(of)g(this,)g(the)0 274 y(resulting)f(programming)f(st)o(yle)g (is)h(often)f(called)i Fo(c)n(ontinuation)e(p)n(assing)g(style)p Fp(,)f(or)h(CPS)g(for)g(short.)71 359 y(T)l(o)e(giv)o(e)h(an)g(example)g(of)f (this)i(idea)f(without)g(reference)g(to)f(I/O,)h(let's)g(consider)g(the)g (use)g(of)g(con)o(tin)o(uations)0 416 y(to)i(manage)g(errors|i.e.,)g(to)f (create)i(the)f(e\013ect)g(of)g(a)g(non-lo)q(cal)i(exit,)f(or)f(call)h(to)f (an)g(error-handler.)24 b(A)17 b(con-)0 472 y(v)o(en)o(tional)f(w)o(a)o(y)e (of)h(handling)i(error)d(v)m(alues)i(in)g(Hask)o(ell)g(migh)o(t)g(b)q(e)f (the)h(follo)o(wing:)71 581 y Fi(data)23 b(Maybe)g(a)286 b(=)24 b(Ok)g(a)f(|)h(Oops)f(String)71 638 y(f)548 b(::)24 b(Int)f(->)h(Maybe)f(Int) 71 694 y(f)g(x)501 b(=)24 b(let)f(y)h(=)g(...)691 751 y(in)47 b(if)24 b(y==0)47 b(then)g(Oops)24 b("divide)f(by)g(zero")786 807 y(else)48 b(Ok)23 b(\(x/y\))0 916 y Fp(Here)c(the)g Fi(Maybe)f Fp(t)o(yp)q(e)h(is)g(used)g(to)f(enco)q(de)i(the)f(p)q(ossibilit)o(y)i(of)d (error)g(in)o(v)o(olving)i(a)f(particular)g(t)o(yp)q(e.)31 b(No)o(w)0 973 y(supp)q(ose)14 b Fi(f)f Fp(is)h(used)g(in)g(con)o(text)e (somewhere;)i(for)f(example,)h(supp)q(ose)g(when)f(the)h(divide-b)o(y-zero)h (error)e(o)q(ccurs)0 1029 y(there)i(is)h(some)f(default)h(v)m(alue)g Fi(d)f Fp(that)g(is)g(appropriate)g(to)g(use)h(instead:)118 1138 y Fi(case)24 b(f)f(z)h(of)166 1195 y(Ok)g(x)71 b(->)24 b(x)166 1251 y(Oops)f(s)h(->)g(d)71 1414 y Fp(In)16 b(con)o(trast)f(to)h (this,)h(an)f(approac)o(h)g(to)f(handling)j(errors)e(based)g(on)h(explicit)h (con)o(tin)o(uations)f(migh)o(t)f(lo)q(ok)0 1470 y(something)f(lik)o(e)i (this:)71 1579 y Fi(f)548 b(::)24 b(Int)f(->)h(\(String)f(->)g(Int\))h(->)f (Int)71 1635 y(f)g(x)h(c)453 b(=)24 b(let)f(y)h(=)g(...)691 1692 y(in)47 b(if)24 b(x==0)47 b(then)g(c)24 b("divide)f(by)h(zero")786 1748 y(else)48 b(x/y)0 1864 y Fp(Note)17 b(that)f(an)h(error)f(con)o(tin)o (uation)i Fi(c)f Fp(is)g(explicitly)j(supplied)g(to)c Fi(f)h Fp(as)f(an)h(argumen)o(t.)1546 1847 y Fm(14)1608 1864 y Fp(No)o(w,)g(to)f (sim)o(ulate)0 1920 y(the)f(ab)q(o)o(v)o(e)g Fo(use)g Fp(of)g Fi(f)p Fp(,)g(w)o(e)f(w)o(ould)i(simply)g(write:)118 2029 y Fi(f)24 b(z)g(\(\\s)f(->)h(d\))71 2192 y Fp(The)12 b(trade-o\013s)f(b)q(et)o (w)o(een)h(con)o(v)o(en)o(tional)h(and)f(con)o(tin)o(uation-based)h(approac)o (hes)f(to)f(handling)j(suc)o(h)f(things)0 2248 y(as)i(errors)f(are)h(sub)s (jectiv)o(e.)20 b(The)c(passing)f(of)g(con)o(tin)o(uations)g(can)h(b)q(e)f (cum)o(b)q(ersome,)h(but)f(on)g(the)g(other)g(hand,)p 0 2295 780 2 v 37 2322 a Fl(14)69 2338 y Fk(As)h(an)h(aside,)h(w)o(e)e(p)q(oin)o(t)h (out)g(that)g(an)f(ev)o(en)h(b)q(etter)g(solution)h(w)o(ould)g(exist)f(if)f (the)h(primitiv)o(e)h(arithmetic)g(functions)g(to)q(ok)0 2383 y(con)o(tin)o(uation)e(argumen)o(ts)e(to)q(o!)j(If)12 b Ff(divide)f Fk(w)o(ere)h(suc)o(h)i(a)f(function)h(for)f Ff(/)g Fk(then)g(w)o(e)g(could)h (simply)h(write:)71 2472 y Ff(f)k(x)g(c)372 b(=)20 b(let)e(y)h(=)g(...)581 2518 y(in)38 b(divide)17 b(x)j(y)f(c)p eop %%Page: 43 43 bop 0 -40 a Fj(8.2)45 b(Con)o(tin)o(uation)15 b(Based)g(I/O)1271 b Fp(T-43)0 105 y(the)12 b(enco)q(ding)g(of)f(error)g(in)o(to)h(sp)q(ecial)h (t)o(yp)q(es)e(is)h(also)g(cum)o(b)q(ersome.)18 b(The)12 b(programmer)e(m)o (ust)h(mak)o(e)g(a)g(judicious)0 162 y(c)o(hoice)16 b(based)g(on)f(her)g (particular)h(circumstances.)71 259 y(Before)e(mo)o(ving)g(on)g(to)f(I/O,)h (ho)o(w)o(ev)o(er,)f(w)o(e)h(p)q(oin)o(t)g(out)g(one)g(\014nal)h(adv)m(an)o (tage)f(of)f(con)o(tin)o(uations)i(b)o(y)f(noting)0 316 y(that)g(if)h Fi(f)g Fp(w)o(ere)f Fo(r)n(e)n(cursive)p Fp(,)g(the)h(error)f(v)m(alue)i(in)f (the)g(con)o(v)o(en)o(tional)g(approac)o(h)f(migh)o(t)h(ha)o(v)o(e)f(to)g(b)q (e)i(propagated)0 372 y(bac)o(k)c(through)f(ev)o(ery)h(lev)o(el)i(of)d (recursion,)i(whereas)f(in)h(the)f(con)o(tin)o(uation-based)h(approac)o(h,)e (the)i(con)o(tin)o(uation)0 429 y(is)f(called)h(directly)l(,)g(m)o(uc)o(h)f (lik)o(e)h(a)e(non-lo)q(cal)i(exit)f(to)e(an)i(error)f(handler!)19 b(This)12 b(ma)o(y)f(ha)o(v)o(e)g(an)h(imp)q(ortan)o(t)f(impact)0 485 y(on)k(e\016ciency)l(.)0 688 y Fg(8.2)56 b(Con)n(tin)n(uation)19 b(Based)g(I/O)0 823 y Fp(Giv)o(en)12 b(this)f(bac)o(kground,)h(understanding) g(con)o(tin)o(uation-based)g(I/O)g(in)g(Hask)o(ell)g(should)g(b)q(e)f (straigh)o(tforw)o(ard;)0 879 y(there)k(are)g(only)h(t)o(w)o(o)e(small)i(t)o (wists.)71 977 y(First,)11 b(a)h(program)f(engaged)h(in)h(I/O)f(\\comm)o (unicates")g(to)f(the)h(outside)h(w)o(orld)f(\(nominally)l(,)i(the)e(op)q (erating)0 1033 y(system\))19 b(using)h(con)o(tin)o(uations.)32 b(A)20 b(Hask)o(ell)g(program)e(engaged)i(in)g(I/O)g(is)g(required)g(to)f(ha) o(v)o(e)g(a)g(top-lev)o(el)0 1090 y(iden)o(ti\014er)j Fi(main)d Fp(whose)h(t)o(yp)q(e)g(is)h Fi(Dialogue)o Fp(;)h(this)e(is)h(the)f(t)o(yp)q (e)g(of)g(the)g(con)o(tin)o(uation)g(that)g(the)g(op)q(erating)0 1146 y(system)15 b(is)g(exp)q(ecting.)71 1244 y(The)j(other)g(t)o(wist)f(is)i (that)f(not)f(only)i(is)g Fo(failur)n(e)f Fp(enco)q(ded)h(as)f(a)g(con)o(tin) o(uation,)h(but)g(so)e(is)i Fo(suc)n(c)n(ess)p Fp(,)e(since)0 1301 y(w)o(e)d(need)i(to)e(con)o(trol)h(the)f(\015o)o(w)h(of)f(all)i(asp)q (ects)e(of)h(I/O.)g(Th)o(us)f(the)h(I/O)g(\\commands")f(in)i(Hask)o (ell|functions)0 1357 y(called)h Fo(tr)n(ansactions)p Fp(|tak)o(e)d Fo(two)h Fp(con)o(tin)o(uation)h(argumen)o(ts,)e(one)h(for)g(success)h(and)f (the)g(other)g(for)g(failure.)71 1455 y(The)d(simplest)h(thing)g(a)f(program) f(could)i(do)f(is)g Fo(halt)p Fp(.)19 b(T)l(o)12 b(do)g(that,)g(w)o(e)g(use)g (the)g(sp)q(ecial)i Fi(done)e Fp(con)o(tin)o(uation,)0 1512 y(whose)j(t)o(yp)q(e)g(is)h Fi(Dialogue)o Fp(:)71 1622 y Fi(main)476 b(=)48 b(done)71 1797 y Fp(F)l(or)18 b(a)g(little)i(more)f(sophistication,)h (supp)q(ose)f(w)o(e)g(wish)g(to)f(write)h(a)g(string)f Fi(s)h Fp(to)f(a)g(\014le)i(whose)f(name)f(is)0 1854 y Fi("ReadMe")o Fp(.)i(W)l(e)15 b(w)o(ould)h(do)f(this)g(in)h(Hask)o(ell)g(using)g(the)g Fi(writeFile)e Fp(transaction:)71 1963 y Fi(main)476 b(=)24 b(writeFile)f("ReadMe")f(s)i(failCont)f(succCont)0 2072 y Fp(where)12 b Fi(failCont)f Fp(and)h Fi(succCont)f Fp(are)h(failure)h(and)f(success)g (con)o(tin)o(uations,)h(resp)q(ectiv)o(ely)l(,)h(that)d(will)j(b)q(e)e(giv)o (en)0 2128 y(sp)q(eci\014c)17 b(v)m(alues)f(later.)k(The)c(t)o(yp)q(e)f(of)g Fi(writeFile)f Fp(is:)71 2237 y Fi(writeFile)356 b(::)24 b(Name)f(->)h (String)f(->)g(FailCont)g(->)h(SuccCont)f(->)g(Dialogue)71 2294 y(type)g(Name)357 b(=)24 b(String)0 2403 y Fp(So)15 b(w)o(e)g(see)h (that)e(the)h(result)h(of)f(the)g(application)i(of)e Fi(writeFile)f Fp(has)h(the)g(appropriate)g(t)o(yp)q(e:)20 b Fi(Dialogue)o Fp(.)71 2501 y(But)g(what)f(exactly)h(are)g Fi(FailCont)e Fp(and)j Fi(SuccCont)n Fp(?)35 b(T)l(o)20 b(answ)o(er)f(that,)h(w)o(e)g(m)o(ust)f (understand)i(what)0 2557 y(kinds)16 b(of)e(\\in)o(termediate)h(v)m(alues")h (are)e(generated)h(b)o(y)f(the)h(v)m(arious)g(transactions.)k(F)l(or)14 b(example,)i Fo(failur)n(e)e Fp(of)g(a)0 2614 y(transaction)h(ma)o(y)f (generate)h(an)o(y)g(of)g(the)g(follo)o(wing)h(kinds)g(of)f(errors:)p eop %%Page: 44 44 bop 0 -40 a Fp(T-44)1417 b Fj(8)45 b(INPUT/OUTPUT)71 160 y Fi(data)23 b(IOError)285 b(=)24 b(WriteError)46 b(String)643 216 y(|)24 b(ReadError)70 b(String)643 272 y(|)24 b(SearchError)e(String)643 329 y(|)i(FormatError)e(String)643 385 y(|)i(OtherError)46 b(String)0 494 y Fp(and)15 b(th)o(us)g Fi(FailCont)f Fp(is)i(de\014ned)h(as:) 71 595 y Fi(type)23 b(FailCont)261 b(=)24 b(IOError)f(->)h(Dialogue)0 704 y Fp(In)16 b(con)o(trast)e(to)g(failure,)i Fo(suc)n(c)n(ess)e Fp(of)g Fi(writeFile)g Fp(do)q(esn't)h(really)h(return)g Fo(anything)p Fp(,)e(so)h Fi(SuccCont)f Fp(is)i(simply:)71 813 y Fi(type)23 b(SuccCont)261 b(=)24 b(Dialogue)0 922 y Fp(A)19 b(simple)h(failure)f(con)o (tin)o(uation)g(that)f(is)h(prede\014ned)h(in)f(Hask)o(ell)h(is)f(one)f(that) g(ignores)h(the)g(error)e(message)0 978 y(and)e(halts:)71 1078 y Fi(abort)452 b(::)24 b(FailCont)71 1135 y(abort)f(err)357 b(=)24 b(done)0 1244 y Fp(A)15 b(b)q(etter)g(one,)g(also)h(prede\014ned,)g (prin)o(ts)f(the)h(error)e(message)h(to)g Fi(stderror)f Fp(b)q(efore)h (halting:)71 1353 y Fi(exit)476 b(::)48 b(FailCont)71 1409 y(exit)23 b(err)381 b(=)48 b(appendChan)22 b(stderr)h(msg)h(abort)f(done)715 1466 y(where)g(msg)h(=)f(case)h(err)f(of)h(ReadError)70 b(s)24 b(->)f(s)1288 1522 y(WriteError)46 b(s)24 b(->)f(s)1288 1579 y(SearchError)f(s)i(->)f(s)1288 1635 y(FormatError)f(s)i(->)f(s)1288 1692 y(OtherError)46 b(s)24 b(->)f(s)71 1850 y Fp(Returning)18 b(no)o(w)g(to)f(the)g(previous)i(example,)g(if)f(what)f(w)o(e)g(w)o(an)o(ted) g(is)i(simply)g(to)e(halt)g(after)g(writing)i(to)0 1906 y(the)c(\014le,)h (and)g(prin)o(t)f(an)o(y)g(error)f(message)h(that)g(migh)o(t)g(arise,)g(w)o (e)g(w)o(ould)g(write:)71 2015 y Fi(main)476 b(=)24 b(writeFile)f("ReadMe")f (s)i(exit)f(done)71 2173 y Fp(The)15 b(transaction)g Fi(readFile)f Fp(returns)h(the)g(con)o(ten)o(ts)g(of)f(a)h(\014le,)h(and)g(th)o(us)f(its)g (t)o(yp)q(e)g(is)h(giv)o(en)g(b)o(y:)71 2282 y Fi(readFile)380 b(::)24 b(Name)f(->)h(FailCont)f(->)g(StrCont)g(->)h(Dialogue)71 2339 y(type)f(StrCont)285 b(=)24 b(String)f(->)h(Dialogue)0 2448 y Fp(F)l(or)15 b(example,)g(w)o(e)g(could)h(use)g(it)f(to)g(read)g(the)g (\014le)i(previously)f(written:)71 2557 y Fi(main)476 b(=)24 b(readFile)f("ReadMe")g(exit)g(\(\\s->...\))p eop %%Page: 45 45 bop 0 -40 a Fj(8.2)45 b(Con)o(tin)o(uation)15 b(Based)g(I/O)1271 b Fp(T-45)0 105 y(where)15 b(the)h Fi(...)e Fp(re\015ects)i(whatev)o(er)e(it) i(is)g(w)o(e)f(wish)g(to)g(do)g(with)h(what)e(w)o(e)h(ha)o(v)o(e)g(read.)71 183 y(Pragmatically)l(,)f(it)h(ma)o(y)e(seem)i(that)e Fi(readFile)g Fp(m)o(ust)h(read)g(an)h(en)o(tire)f(\014le,)h(resulting)h(in)f(p)q(o)q(or)f (space)h(and)0 240 y(time)k(p)q(erformance)g(under)h(certain)g (circumstances.)32 b(Ho)o(w)o(ev)o(er,)18 b(this)i(is)f(not)g(the)g(case.)31 b(The)19 b(k)o(ey)g(p)q(oin)o(t)g(is)0 296 y(that)c Fi(readFile)g Fp(returns)h(a)g(\\lazy")g(\(i.e.)23 b(non-strict\))16 b(list)h(of)f(c)o (haracters)f(\(recall)i(that)f(strings)g(are)f(just)h(lists)0 353 y(of)e(c)o(haracters)g(in)i(Hask)o(ell\),)f(whose)g(elemen)o(ts)g(are)f (read)h(\\b)o(y)g(demand")g(just)f(lik)o(e)i(an)o(y)e(other)h(list.)20 b(An)15 b(imple-)0 409 y(men)o(tation)f(can)g(b)q(e)h(exp)q(ected)h(to)e (implemen)o(t)h(this)g(demand-driv)o(en)h(b)q(eha)o(vior)f(b)o(y)f(reading)h (one)f(c)o(haracter)g(at)0 465 y(a)h(time)g(from)g(the)g(\014le.)71 543 y(There)k(are)g(lots)h(of)f(other)g(transactions)g(a)o(v)m(ailable)i(in)f (the)g(Hask)o(ell)g(I/O)g(design,)h(whic)o(h)f(primarily)h(re-)0 600 y(\015ects)d(the)g(desire)h(for)e(compatibilit)o(y)j(with)e(con)o(v)o(en) o(tional)g(op)q(erating)g(systems.)27 b(F)l(or)18 b(example,)h(there)f(is)g (an)0 656 y Fi(appendFile)e Fp(transaction)g(whic)o(h)i(writes)f(a)f(string)h (to)g(the)g(end)g(of)g(a)f(\014le.)26 b(There)18 b(are)e(also)h Fo(binary)g Fp(v)o(ersions)0 713 y(of)e Fi(readFile)o Fp(,)f Fi(writeFile)o Fp(,)h(and)g Fi(appendFile)f Fp(\()p Fn(x)p Fp(7\).)71 791 y(Also)h(included)j(among)c(the)h(standard)f(op)q(erations)i (are)e(those)h(whic)o(h)h(in)o(teract)f(with)g Fo(channels)p Fp(,)e(whic)o(h)j(in)0 847 y(Unix-land)k(includes)g(things)e(lik)o(e)h (standard-input,)g(standard-output,)f(etc.)27 b(The)19 b(t)o(w)o(o)d(most)h (imp)q(ortan)o(t)g(of)0 904 y(these)e(are:)71 1004 y Fi(readChan)380 b(::)24 b(Name)f(->)262 b(FailCont)23 b(->)h(StrCont)47 b(->)23 b(Dialogue)71 1060 y(appendChan)332 b(::)24 b(Name)f(->)h(String)f(->)g (FailCont)g(->)h(SuccCont)f(->)g(Dialogue)0 1169 y Fp(There)12 b(is)g(no)g Fi(writeChan)f Fp(transaction,)h(since)h(the)f(output)f(is)i(alw) o(a)o(ys)e(app)q(ended)i(to)e(whatev)o(er)h(w)o(as)f(previously)0 1226 y(written)k(\(th)o(us)g Fi(appendChan)f Fp(is)h(akin)h(to)f Fi(appendFile)n Fp(\).)71 1304 y(Note)g(that)h(c)o(hannel)h(names)f(are)g (just)f(strings)h(\(lik)o(e)h(\014le)g(names\).)23 b(There)16 b(are)g(four)f(c)o(hannel)j(names)e(that)0 1360 y(are)f(alw)o(a)o(ys)f(supp)q (orted)i(b)o(y)f(a)g(prop)q(er)h(implemen)o(tation,)g(and)f(are)g(b)q(ound)h (to)f(the)g(follo)o(wing)h(iden)o(ti\014ers:)71 1469 y Fi(stdin)452 b(=)48 b("stdin")71 1526 y(stdout)428 b(=)48 b("stdout")71 1582 y(stderr)428 b(=)48 b("stderr")71 1639 y(stdecho)404 b(=)48 b("stdecho")0 1750 y Fp(On)12 b(most)f(systems,)g Fi(stdout)p Fp(,)g Fi(stderr)p Fp(,)h(and)f Fi(stdecho)g Fp(all)h(represen)o(t)g(the)g (same)f(ph)o(ysical)i(c)o(hannel)g(\(nominally)l(,)0 1807 y(the)i(user's)g (terminal)h(displa)o(y\).)71 1885 y(Let's)k(no)o(w)g(consider)h(a)f(sligh)o (tly)i(bigger)f(program|one)f(that)f(writes)i(to)f(a)g(\014le,)i(reads)e(the) h(\014le)g(bac)o(k,)0 1941 y(compares)15 b(the)h(con)o(ten)o(ts)e(for)h (equalit)o(y)h(with)g(what)f(w)o(as)f(previously)j(written,)e(prin)o(ts)h(a)f (suitable)i(message)e(to)0 1998 y(standard)g(output,)f(and)i(halts:)71 2107 y Fi(main)94 b(=)24 b(writeFile)f("ReadMe")g(s1)g(exit)h(\()309 2163 y(readFile)47 b("ReadMe")94 b(exit)24 b(\(\\s2->)309 2220 y(appendChan)f(stdout)g(\(if)g(s1==s2)g(then)h("contents)e(match")1001 2276 y(else)i("something)e(intervened!"\))g(exit)309 2333 y(done\)\))0 2444 y Fp(This)f(program)e(demonstrates)g(an)h(imp)q(ortan)o(t)f(asp)q(ect)i (of)e(Hask)o(ell)i(I/O|it)g(p)q(ermits)g Fo(nondeterminism)e Fp(in)0 2501 y(the)e(op)q(erating)g(system)f(\(if)h(it)g(didn't,)g(it)g(w)o (ould)g(hardly)h(b)q(e)f(practical!\),)g(y)o(et)f(in)o(ternally)j(programs)c (are)i(still)0 2557 y(referen)o(tially)d(transparen)o(t.)k(In)13 b(this)g(example)h(there)f(is)g(the)f(p)q(ossibilit)o(y)j(\(alb)q(eit)f (small\))f(that)f(the)h(test)f Fi(s1==s2)0 2614 y Fp(will)17 b(fail,)e(b)q(ecause)h(some)e(other)h(agen)o(t)f(ma)o(y)g(mo)q(dify)h(the)g (\014le)h(b)q(et)o(w)o(een)f(the)g(times)g(it)g(w)o(as)f(written)h(and)g (read.)p eop %%Page: 46 46 bop 0 -40 a Fp(T-46)1417 b Fj(8)45 b(INPUT/OUTPUT)71 105 y Fp(Also)16 b(note)g(ho)o(w)g(this)g(program)f(is)i(formatted,)e(giving)i(it)f (an)g(\\imp)q(erativ)o(e)h(feel.")24 b(W)l(e)16 b(can)g(enhance)i(this)0 162 y(st)o(yle)d(b)o(y)g(using)h(an)g(in\014x)g(apply)g(op)q(erator:)71 271 y Fi(infixr)23 b(0)g($)71 327 y(f)g($)h(a)71 b(=)24 b(f)g(a)71 407 y(main)94 b(=)24 b(writeFile)47 b("ReadMe")22 b(s1)i(exit)f($)309 463 y(readFile)71 b("ReadMe")94 b(exit)23 b($)h(\\s2->)309 520 y(appendChan)f(stdout)g(\(if)g(s1==s2)g(then)h("contents)e(match")1001 576 y(else)i("somebody)e(intervened!"\))g(exit)i($)309 632 y(done)0 742 y Fp(This)12 b(v)o(ersion)h(has)e(the)h(adv)m(an)o(tage)g(of)f (not)h(requiring)h(the)f(nesting)g(of)g(paren)o(theses,)g(whic)o(h)h(in)f (larger)g(programs)0 798 y(can)j(b)q(ecome)h(quite)g(anno)o(ying.)0 1050 y Fg(8.3)56 b(T)-5 b(erminal)16 b(I/O)0 1208 y Fp(Sp)q(ecial)h(men)o (tion)d(should)i(b)q(e)f(made)g(of)f(reading)h(from)f(standard)g(input,)h(in) g(that)f(what)g(is)h(returned)g(is)g(a)f(lazy)0 1264 y(string,)f(just)g(as)g (for)g(a)g(\014le.)20 b(The)13 b(\014rst)g(issue)h(that)f(arises)g(is)h (whether)f(the)h(input)g(is)g(\\ec)o(ho)q(ed")f(on)g(the)h(terminal,)0 1320 y(or)e(whether)h(the)g(user)f(is)h(required)h(to)e(do)h(so)f(explicitly) l(.)22 b(The)13 b(answ)o(er)f(is)h(that)f(w)o(e)g(ha)o(v)o(e)g(a)h(c)o (hoice!)20 b(The)12 b(default)0 1377 y(is)k(that)f(ec)o(hoing)i(is)f(\\on,")f (but)g(it)h(can)g(b)q(e)g(turned)h(o\013)d(\(or)h(on\))h(using)g(the)g Fi(echo)f Fp(transaction,)g(whic)o(h)h(tak)o(es)f(a)0 1433 y(b)q(o)q(olean)h(argumen)o(t)f(along)g(with)g(the)h(\(ubiquitous\))g (failure)g(and)f(success)h(con)o(tin)o(uations:)71 1545 y Fi(echo)476 b(::)24 b(Bool)f(->)h(FailCont)f(->)g(SuccCont)g(->)h(Dialogue)0 1654 y Fp(T)l(urning)19 b(ec)o(hoing)f(o\013)f(w)o(ould)h(b)q(e)g(required)h (if,)f(for)f(example,)h(w)o(e)g(w)o(an)o(ted)f(to)g(write)g(a)h(screen-orien) o(ted)g(text)0 1710 y(editor.)71 1823 y(Since)13 b(the)f(result)g(of)f (reading)i(from)e Fi(stdin)g Fp(is)h(a)g(lazy)g(string,)g(that)f(means)h(it)g (only)g(has)g(to)f(b)q(e)h(done)h Fo(onc)n(e)e Fp(for)0 1880 y(a)k(giv)o(en)h(program|indeed,)g(a)f(run-time)i(error)e(will)i(result)f(if) f(it)h(is)g(done)g(more)f(than)g(once.)21 b(But)16 b(this)g(raises)0 1936 y(the)f(follo)o(wing)g(question:)20 b(if)c(ec)o(hoing)f(is)g(enabled,)h (the)f(input)h(stream)d(will)k(app)q(ear)e(on)f(the)h Fi(stdecho)f Fp(c)o(hannel)0 1993 y(\(whic)o(h)k(on)g(most)f(systems)h(is)g(synon)o(ymous) g(with)g Fi(stdout)o Fp(\);)h(but)f(then)g(ho)o(w)f(is)i(this)f(output)g (\\in)o(terlea)o(v)o(ed")0 2049 y(with)e(explicit)h(output)e(to)f(the)i(same) f(c)o(hannel?)71 2162 y(T)l(o)c(giv)o(e)h(a)g(formal)g(answ)o(er)f(to)h(this) g(question)h(requires)f(de\014ning)i(precisely)g(the)e(b)q(eha)o(vior)g(of)g (the)g(op)q(erating)0 2218 y(system;)j(that's)g(wh)o(y)g(in)i(the)e(App)q (endix)j(of)d(the)h(Rep)q(ort)g(a)g(sp)q(eci\014cation)h(of)e(the)h(op)q (erating)g(system)f(is)h(giv)o(en)0 2275 y(in)g(Hask)o(ell)g(co)q(de.)21 b(Here,)15 b(w)o(e)g(simply)h(giv)o(e)f(an)h(op)q(erational)f(description)i (of)e(the)g(exp)q(ected)i(b)q(eha)o(vior.)71 2388 y(First,)e(w)o(e)h(m)o(ust) g(consider)h(whether)f(ec)o(hoing)h(is)g(enabled)g(or)f(disabled.)25 b(With)16 b(ec)o(ho)g(enabled,)i(w)o(e)e(w)o(ould)0 2444 y(exp)q(ect)h(line)h (editing)f(functions)g(lik)o(e)g(\\rub)q(out")f(to)g(b)q(e)g(handled)i Fo(b)n(efor)n(e)e Fp(the)g(program)f(is)h(allo)o(w)o(ed)h(to)e(see)i(the)0 2501 y(result,)i(and)f(indeed)i(that's)d(what)g(happ)q(ens)i(in)g(Hask)o (ell.)29 b(This)19 b(means)f(that)f(the)h(user)g(input)h(is)g(e\013ectiv)o (ely)0 2557 y(seen)e(\\line-at-a-time,")h(since)f(a)f(series)h(of)f(rub)q (outs)h(could)h(o)q(ccur)e(at)g(an)o(y)g(p)q(oin)o(t)h(in)h(the)e(line.)26 b(Consider,)17 b(for)0 2614 y(example,)f(this)f(program:)p eop %%Page: 47 47 bop 0 -40 a Fj(8.4)45 b(Finer)15 b(Lev)o(el)i(of)d(Con)o(trol)1311 b Fp(T-47)71 160 y Fi(main)285 b(=)24 b(echo)f(flag)h(exit)262 b($)500 216 y(readChan)23 b(stdin)g(exit)143 b($)23 b(\\s->)500 272 y(appendChan)g(stdout)g(s)g(exit)h($)500 329 y(done)0 438 y Fp(If)13 b Fi(flag)e Fp(is)i Fi(True)p Fp(,)f(ec)o(hoing)h(will)h(b)q(e)f (enabled,)h(and)e(the)h(user)f(will)i(b)q(e)f(able)g(to)f(t)o(yp)q(e)g(an)g (en)o(tire)h(line,)h(with)f(correc-)0 494 y(tions)k(b)q(eing)h(dutifully)h (pro)q(cessed.)25 b(When)17 b(a)f(new-line)j(c)o(haracter)d(is)h(t)o(yp)q (ed,)g(the)g Fi(appendChan)e Fp(transaction)0 551 y(will)20 b(then)f(b)q(e)g(able)g(to)f(\\see")g(the)h(result,)g(and)g(will)h(th)o(us)e (displa)o(y)h(the)g(line)h(just)e(t)o(yp)q(ed,)h(with)g(corrections.)0 607 y(This)d(pro)q(cess)f(will)i(then)f(rep)q(eat)f(for)g(subsequen)o(t)h (lines;)g(in)g(other)f(w)o(ords,)f(the)h(ec)o(hoing)h(and)g(explicit)h (output)0 664 y(are)f(in)o(terlea)o(v)o(ed)h(line-at-a-time.)26 b(Note)16 b(that)g(this)h(program)e(is)i(essen)o(tially)h(in)f(an)g (in\014nite)h(lo)q(op,)f(unless)h(the)0 720 y(user)h(terminates)h(the)f (input)h(sequence)h(\(suc)o(h)e(as)g(via)h(Cn)o(trl-D)f(in)h(a)f(Unix)h(en)o (vironmen)o(t\),)g(in)g(whic)o(h)g(case)0 777 y Fi(appendChan)14 b Fp(can)h(\014nish)i(its)e(task.)71 858 y(On)j(the)h(other)f(hand,)h(if)f Fi(flag)g Fp(is)h Fi(False)o Fp(,)g(ec)o(hoing)g(is)f(disabled,)j(and)d Fi(appendChan)f Fp(will)j(see)f(the)f(input)0 915 y(c)o(haracter-b)o(y-c)o (haracter.)g(Th)o(us)12 b(the)g(e\013ect)f(of)h Fi(appendChan)e Fp(will)k(b)q(e)f(to)e(do)h(c)o(haracter-b)o(y-c)o(haracter)f(ec)o(hoing!)71 996 y(The)17 b(other)f(factor)g(in)i(determining)g(the)g(in)o(terlea)o(ving)g (b)q(eha)o(vior)f(is)h(the)f(degree)g(to)f(whic)o(h)i(the)f(program)0 1052 y Fo(dep)n(ends)j Fp(on)h(the)g(input)h(stream.)36 b(F)l(or)20 b(example,)j(a)e(program)f(that)g(prin)o(ts)h(one)g Fi("X")g Fp(for)f(ev)o(ery)h(10)f(input)0 1109 y(c)o(haracters)14 b(will)j(b)q(eha)o (v)o(e)f(as)f(exp)q(ected;)h(here)f(is)h(suc)o(h)f(a)g(program:)71 1218 y Fi(main)94 b(=)24 b(readChan)f(stdin)g(exit)g($)h(\\s->)309 1274 y(let)g(loop)f(n)48 b([])310 b(=)23 b(done)405 1331 y(loop)g(n)h (\(x:xs\))f(|)g(n==10)48 b(=)23 b(appendChan)g(stdout)g("X")g(exit)h($)1001 1387 y(loop)95 b(1)48 b(xs)739 1444 y(|)23 b(True)72 b(=)23 b(loop)h(\(n+1\))f(xs)309 1500 y(in)h(loop)f(1)h(s)0 1612 y Fp(This)19 b(program)e(also)h(demonstrates)g(ho)o(w)f(to)h(write)g(a)g(lo)q (op)h(\(i.e.)f(a)g(recursion\))g(using)h(con)o(tin)o(uations.)30 b(\(See)0 1668 y Fn(x)p Fp(7.7)14 b(for)h(another)g(example)h(of)f(sync)o (hronizing)h(input)h(with)e(output.\))71 1750 y(There)g(are)g(sev)o(eral)g(v) o(ery)g(useful)h(prede\014ned)h(functions)f(in)g(Hask)o(ell)g(that)f(mak)o(e) f(in)o(teractions)i(with)f(stan-)0 1806 y(dard)20 b(input)h(and)f(output)g (relativ)o(ely)h(painless.)36 b(These)21 b(are)e Fi(print)p Fp(,)h Fi(prints)p Fp(,)g(and)h Fi(interact)o Fp(,)f(whic)o(h)h(are)0 1862 y(describ)q(ed)c(in)f(Section)g Fn(x)p Fp(7.5)f(of)f(the)i(Rep)q(ort.)0 2009 y Fg(8.4)56 b(Finer)18 b(Lev)n(el)f(of)i(Con)n(trol)0 2120 y Fp(Sometimes)c(\(although)f(rarely\))g(the)h(user)f(will)i(need)g(a)e (\014ner)h(lev)o(el)h(of)e(con)o(trol)g(o)o(v)o(er)f(I/O)i(than)f(that)g(pro) o(vided)0 2176 y(b)o(y)g(the)f(standard)h(set)f(of)g(I/O)h(transactions)f (pro)o(vided)i(in)f(Hask)o(ell)h(\(for)e(example,)h(sometimes)g(it)g(is)g (necessary)0 2233 y(to)f(explicitly)k(op)q(en)e(and)f(close)h(\014les\).)20 b(This)15 b(fact)e(is)i(recognized)g(in)g(App)q(endix)h Fn(x)p Fp(C,)e(where)g(an)g(alternativ)o(e)g(set)0 2289 y(of)h(I/O)g(op)q(erations)h (is)f(suggested)h(and)f(that)f(some)h(implemen)o(tations)i(ma)o(y)d(supp)q (ort.)p eop %%Page: 48 48 bop 0 -40 a Fp(T-48)1597 b Fj(9)45 b(ARRA)l(YS)0 105 y Fq(9)69 b(Arra)n(ys)0 236 y Fp(Ideally)l(,)13 b(arra)o(ys)d(in)i(a)f(functional)h (language)f(w)o(ould)g(b)q(e)h(regarded)f(simply)h(as)f(functions)h(from)e (indices)j(to)d(v)m(alues,)0 292 y(but)16 b(pragmatically)l(,)g(in)h(order)e (to)g(assure)h(e\016cien)o(t)g(access)g(to)f(arra)o(y)g(elemen)o(ts,)h(w)o(e) f(need)i(to)e(b)q(e)h(sure)g(w)o(e)g(can)0 349 y(tak)o(e)h(adv)m(an)o(tage)g (of)h(the)g(sp)q(ecial)h(prop)q(erties)g(of)e(the)h(domains)g(of)g(these)g (functions,)h(whic)o(h)f(are)g(isomorphic)0 405 y(to)h(\014nite)i(con)o (tiguous)f(subsets)g(of)f(the)h(in)o(tegers.)34 b(Hask)o(ell,)21 b(therefore,)f(do)q(es)g(not)g(treat)f(arra)o(ys)f(as)h(general)0 462 y(functions)d(with)f(an)h(application)g(op)q(eration,)g(but)f(as)g (abstract)f(data)g(t)o(yp)q(es)i(with)f(a)g(subscript)h(op)q(eration.)71 546 y(Tw)o(o)11 b(main)h(approac)o(hes)g(to)f(functional)j(arra)o(ys)c(ma)o (y)i(b)q(e)g(discerned:)20 b Fo(incr)n(emental)11 b Fp(and)h Fo(monolithic)g Fp(de\014ni-)0 603 y(tion.)20 b(In)15 b(the)f(incremen)o(tal) h(case,)f(w)o(e)g(ha)o(v)o(e)g(a)g(function)h(that)e(pro)q(duces)i(an)g(empt) o(y)e(arra)o(y)g(of)h(a)g(giv)o(en)h(size)g(and)0 659 y(another)f(that)f(tak) o(es)g(an)h(arra)o(y)l(,)f(an)h(index,)h(and)f(a)g(v)m(alue,)h(pro)q(ducing)g (a)f(new)g(arra)o(y)f(that)g(di\013ers)h(from)f(the)h(old)0 716 y(one)i(only)g(at)f(the)h(giv)o(en)h(index.)23 b(Ob)o(viously)l(,)17 b(a)e(naiv)o(e)i(implemen)o(tation)g(of)e(suc)o(h)h(an)g(arra)o(y)f(seman)o (tics)h(w)o(ould)0 772 y(b)q(e)h(in)o(tolerably)g(ine\016cien)o(t,)g (requiring)g(a)e(new)h(cop)o(y)g(of)g(an)f(arra)o(y)g(for)g(eac)o(h)h (incremen)o(tal)h(rede\014nition;)h(th)o(us,)0 829 y(serious)13 b(attempts)e(at)g(using)i(this)f(approac)o(h)g(emplo)o(y)h(sophisticated)g (static)f(analysis)g(and)h(clev)o(er)g(run-time)f(de-)0 885 y(vices)j(to)f(a)o(v)o(oid)h(excessiv)o(e)g(cop)o(ying.)20 b(The)15 b(monolithic)h(approac)o(h,)e(on)g(the)h(other)f(hand,)h(constructs) f(an)g(arra)o(y)0 941 y(all)k(at)f(once,)g(without)g(reference)h(to)f(in)o (termediate)g(arra)o(y)f(v)m(alues.)27 b(Although)18 b(Hask)o(ell)g(has)f(an) g(incremen)o(tal)0 998 y(arra)o(y)d(up)q(date)i(op)q(erator,)e(the)h(main)h (thrust)e(of)h(the)g(arra)o(y)f(facilit)o(y)j(is)e(monolithic.)0 1155 y Fg(9.1)56 b(Index)18 b(t)n(yp)r(es)0 1270 y Fp(The)d(Standard)h (Prelude)g(de\014nes)g(a)f(t)o(yp)q(e)g(class)h(of)f(arra)o(y)f(indices:)71 1379 y Fi(class)47 b(\(Ord)23 b(a\))h(=>)f(Ix)h(a)47 b(where)166 1436 y(range)166 b(::)24 b(\(a,a\))f(->)h([a])166 1492 y(index)166 b(::)24 b(\(a,a\))f(a)h(->)f(Int)166 1549 y(inRange)118 b(::)24 b(\(a,a\))f(->)h(a)f(->)h(Bool)0 1658 y Fp(Instance)12 b(declarations)g(are)e (pro)o(vided)i(for)f Fi(Int)o Fp(,)h Fi(Integer)o Fp(,)f Fi(Char)p Fp(,)g Fi(Bool)p Fp(,)g(and)h(tuples)g(of)e Fi(Ix)h Fp(t)o(yp)q(es;)h(in)g (addition,)0 1714 y(instances)17 b(ma)o(y)e(b)q(e)i(automatically)f(deriv)o (ed)h(for)f(en)o(umerated)g(and)g(tuple)h(t)o(yp)q(es.)23 b(W)l(e)16 b(regard)f(the)i(primitiv)o(e)0 1771 y(t)o(yp)q(es)j(as)f(v)o(ector)g (indices)i(and)f(tuples)h(as)e(indices)i(of)f(m)o(ultidimensional)i (rectangular)e(arra)o(ys.)31 b(Note)20 b(that)0 1827 y(the)c(\014rst)g (argumen)o(t)f(of)h(eac)o(h)g(of)f(the)h(op)q(erations)h(of)e(class)h Fi(Ix)g Fp(is)h(a)e(pair)i(of)e(indices;)j(these)f(are)e(t)o(ypically)j(the)0 1883 y Fo(b)n(ounds)g Fp(\(\014rst)f(and)h(last)g(indices\))i(of)e(an)g(arra) o(y)l(.)28 b(F)l(or)17 b(example,)j(the)e(b)q(ounds)h(of)f(a)f(10-elemen)o (t,)i(zero-origin)0 1940 y(v)o(ector)13 b(with)h Fi(Int)f Fp(indices)j(w)o (ould)e(b)q(e)h Fi(\(0,9\))o Fp(,)f(while)h(a)e(100)g(b)o(y)h(100)f(1-origin) h(matrix)f(migh)o(t)h(ha)o(v)o(e)f(the)h(b)q(ounds)0 1996 y Fi(\(\(1,1\),\(100,100\)\))n Fp(.)38 b(\(In)22 b(man)o(y)e(other)h (languages,)i(suc)o(h)f(b)q(ounds)g(w)o(ould)g(b)q(e)g(written)f(in)h(a)f (form)g(lik)o(e)0 2053 y Fi(1:100,)i(1:100)o Fp(,)17 b(but)g(the)g(presen)o (t)f(form)g(\014ts)h(the)g(t)o(yp)q(e)g(system)f(b)q(etter,)h(since)g(eac)o (h)g(b)q(ound)h(is)f(of)f(the)h(same)0 2109 y(t)o(yp)q(e)e(as)g(a)g(general)h (index.\))71 2194 y(The)g Fi(range)g Fp(op)q(eration)g(tak)o(es)g(a)f(b)q (ounds)j(pair)e(and)h(pro)q(duces)g(the)f(list)h(of)f(indices)i(lying)g(b)q (et)o(w)o(een)e(those)0 2250 y(b)q(ounds,)g(in)g(index)g(order.)k(F)l(or)14 b(example,)617 2357 y Fi(range)23 b(\(0,4\))72 b Fn(\))i Fi([0,1,2,3,4])151 2468 y(range)23 b(\(\(0,0\),\(1,2\)\))72 b Fn(\))i Fi([\(0,0\),)22 b(\(0,1\),)h(\(0,2\),)h(\(1,0\),)f(\(1,1\),)g(\(1,2\)])0 2557 y Fp(The)17 b Fi(inRange)g Fp(predicate)h(determines)g(whether)f(an)g(index)i (lies)f(b)q(et)o(w)o(een)g(a)e(giv)o(en)i(pair)g(of)e(b)q(ounds.)27 b(\(F)l(or)16 b(a)0 2614 y(tuple)d(t)o(yp)q(e,)f(this)g(test)f(is)h(p)q (erformed)g(comp)q(onen)o(t)o(wise.\))19 b(Finally)l(,)14 b(the)e Fi(index)f Fp(op)q(eration)h(is)g(what)f(is)i(needed)g(to)p eop %%Page: 49 49 bop 0 -40 a Fj(9.2)45 b(Arra)o(y)14 b(Creation)1451 b Fp(T-49)0 105 y(address)13 b(a)g(particular)h(elemen)o(t)g(of)f(an)g(arra)o(y:)k(Giv)o (en)d(a)f(b)q(ounds)h(pair)g(and)f(an)g(in-range)h(index,)g(the)g(op)q (eration)0 162 y(yields)j(the)e(zero-origin)h(ordinal)g(of)f(the)g(index)i (within)f(the)f(range;)g(for)g(example:)712 259 y Fi(index)23 b(\(1,9\))g(2)73 b Fn(\))h Fi(1)569 357 y(index)23 b(\(\(0,0\),\(1,2\)\))f (\(1,1\))73 b Fn(\))g Fi(5)0 501 y Fg(9.2)56 b(Arra)n(y)19 b(Creation)0 610 y Fp(Hask)o(ell's)h(monolithic)h(arra)o(y)d(creation)i (function)h(forms)d(an)i(arra)o(y)e(from)h(a)g(pair)h(of)f(b)q(ounds)i(and)f (a)f(list)h(of)0 666 y(index-v)m(alue)e(pairs)d(\(an)g Fo(asso)n(ciation)h (list)p Fp(\):)71 778 y Fi(array)452 b(::)24 b(\(Ix)f(a\))h(=>)g(\(a,a\))f (->)g([Assoc)g(a)h(b])g(->)f(Array)g(a)h(b)0 887 y Fp(Notice)15 b(the)f(t)o(yp)q(e)h Fi(Assoc)o Fp(;)f(to)g(impro)o(v)o(e)g(the)h(readabilit) o(y)g(of)f(arra)o(y)f(expressions,)i(the)f(pairs)h(in)g(the)g(asso)q(ciation) 0 944 y(list)h(are)f(not)g(of)f(the)i(ordinary)f(sort,)f(but)h(of)g(another)g (tuple)h(t)o(yp)q(e)f(with)h(the)f(data)g(constructor)f Fi(\(:=\))p Fp(:)71 1053 y Fi(data)47 b(Assoc)23 b(a)h(b)214 b(=)48 b(a)24 b(:=)f(b)0 1162 y Fp(Here,)15 b(for)g(example,)g(is)h(a)f(de\014nition)i(of)e (an)g(arra)o(y)f(of)h(the)g(squares)g(of)g(n)o(um)o(b)q(ers)g(from)f(1)h(to)g (100:)71 1271 y Fi(squares)404 b(=)48 b(array)23 b(\(1,100\))g([i)h(:=)f(i)h (*)g(i)f(|)h(i)g(<-)f([1..100]])0 1380 y Fp(This)17 b(arra)o(y)e(expression)j (is)f(t)o(ypical)g(in)h(using)f(a)f(list)h(comprehension)h(for)e(the)h(asso)q (ciation)g(list;)g(in)h(fact,)e(this)0 1436 y(usage)e(results)h(in)g(arra)o (y)e(expressions)i(m)o(uc)o(h)f(lik)o(e)h(the)g Fo(arr)n(ay)g(c)n(ompr)n (ehensions)e Fp(of)h(the)g(language)h(Id[4].)k(Arra)o(y)0 1493 y(subscripting)f(is)f(p)q(erformed)g(with)g(the)g(in\014x)g(op)q(erator)f Fi(!)p Fp(,)g(and)h(the)g(b)q(ounds)g(of)f(an)h(arra)o(y)e(can)i(b)q(e)g (extracted)0 1549 y(with)f(the)f(function)h Fi(bounds)o Fp(:)748 1606 y Fi(squares!7)72 b Fn(\))h Fi(49)628 1687 y(bounds)24 b(squares)72 b Fn(\))h Fi(\(1,100\))0 1768 y Fp(W)l(e)15 b(migh)o(t)f (generalize)j(this)e(example)g(b)o(y)g(parameterizing)h(the)e(b)q(ounds)i (and)f(the)g(function)g(to)g(b)q(e)g(applied)i(to)0 1824 y(eac)o(h)e(index:) 71 1924 y Fi(mkArray)404 b(::)24 b(\(Ix)f(a\))h(=>)g(\(a)f(->)h(b\))f(->)h (\(a,a\))f(->)h(Array)f(a)h(b)71 1981 y(mkArray)e(f)i(bnds)238 b(=)48 b(array)23 b(bnds)g([i)h(:=)g(f)f(i)h(|)g(i)f(<-)h(range)f(bnds])0 2090 y Fp(Th)o(us,)15 b(w)o(e)g(could)h(de\014ne)g Fi(squares)e Fp(as)h Fi(mkArray)23 b(\(\\i)h(->)f(i)h(*)g(i\))f(\(1,100\))o Fp(.)71 2170 y(Man)o(y)12 b(arra)o(ys)g(are)h(de\014ned)i(recursiv)o(ely;)g (that)e(is,)g(with)h(the)g(v)m(alues)g(of)f(some)g(elemen)o(ts)h(dep)q (ending)i(on)d(the)0 2226 y(v)m(alues)j(of)f(others.)20 b(Here,)15 b(for)f(example,)i(w)o(e)f(ha)o(v)o(e)g(a)f(function)i(returning)g(an)f(arra) o(y)f(of)h(Fib)q(onacci)i(n)o(um)o(b)q(ers:)71 2335 y Fi(fibs)94 b(::)24 b(Int)g(->)f(Array)g(Int)h(Int)71 2392 y(fibs)f(n)47 b(=)h(a)g(where)23 b(a)h(=)f(array)g(\(0,n\))h(\([0)f(:=)h(1,)f(1)h(:=)g(1])f (++)954 2448 y([i)g(:=)h(a!\(i-2\))f(+)g(a!\(i-1\))g(|)h(i)g(<-)f([2..n]]\))0 2557 y Fp(Another)18 b(example)i(of)e(suc)o(h)h(a)f(recurrence)h(is)g(the)g Fo(n)i Fp(b)o(y)e Fo(n)i(wavefr)n(ont)d Fp(matrix,)h(in)g(whic)o(h)h(elemen)o (ts)f(of)f(the)0 2614 y(\014rst)f(ro)o(w)e(and)j(\014rst)e(column)i(all)g(ha) o(v)o(e)e(the)h(v)m(alue)h Fo(1)24 b Fp(and)17 b(other)f(elemen)o(ts)i(are)e (sums)h(of)g(their)g(neigh)o(b)q(ors)h(to)p eop %%Page: 50 50 bop 0 -40 a Fp(T-50)1597 b Fj(9)45 b(ARRA)l(YS)0 105 y Fp(the)15 b(w)o(est,)f(north)o(w)o(est,)g(and)h(north:)71 214 y Fi(wavefront)165 b(::)24 b(Int)f(->)h(Array)f(\(Int,Int\))g(Int)71 271 y(wavefront)f(n)119 b(=)48 b(a)g(where)524 327 y(a)24 b(=)f(array)h(\(\(1,1\),\(n,n\)\))643 383 y(\([\(1,j\))f(:=)h(1)g(|)f(j)h(<-)g([1..n]])e(++)667 440 y([\(i,1\))h(:=)h(1)g(|)f(i)h(<-)g([2..n]])e(++)667 496 y([\(i,j\))h(:=)h (a!\(i,j-1\))e(+)i(a!\(i-1,j-1\))f(+)g(a!\(i-1,j\))954 553 y(|)g(i)h(<-)g([2..n],)e(j)i(<-)g([2..n]]\))0 662 y Fp(The)13 b(w)o(a)o(v)o(efron)o(t)d(matrix)i(is)h(so)f(called)i(b)q(ecause)g(in)f(a)f (parallel)i(implemen)o(tation,)g(the)f(recurrence)g(dictates)g(that)0 718 y(the)f(computation)h(can)f(b)q(egin)h(with)g(the)f(\014rst)g(ro)o(w)f (and)i(column)g(in)g(parallel)h(and)e(pro)q(ceed)h(as)f(a)g(w)o(edge-shap)q (ed)0 775 y(w)o(a)o(v)o(e,)17 b(tra)o(v)o(elling)i(from)e(north)o(w)o(est)g (to)g(southeast.)28 b(It)18 b(is)g(imp)q(ortan)o(t)g(to)f(note,)h(ho)o(w)o (ev)o(er,)g(that)f(no)h(order)f(of)0 831 y(computation)e(is)h(sp)q(eci\014ed) h(b)o(y)e(the)h(asso)q(ciation)f(list.)71 959 y(In)h(eac)o(h)h(of)e(our)h (examples)h(so)f(far,)f(w)o(e)h(ha)o(v)o(e)g(giv)o(en)h(a)f(unique)h(asso)q (ciation)g(for)e(eac)o(h)i(index)g(of)f(the)g(arra)o(y)0 1015 y(and)j(only)f(for)g(the)h(indices)h(within)g(the)e(b)q(ounds)h(of)f(the)h (arra)o(y)l(,)e(and)i(indeed,)h(w)o(e)e(m)o(ust)g(do)g(this)h(in)g(general)0 1072 y(for)14 b(an)h(arra)o(y)f(b)q(e)i(fully)h(de\014ned.)k(An)15 b(asso)q(ciation)h(with)f(an)g(out-of-b)q(ounds)h(index)g(results)f(in)h(an)f (error;)f(if)i(an)0 1128 y(index)g(is)e(missing)i(or)d(app)q(ears)i(more)f (than)g(once,)g(ho)o(w)o(ev)o(er,)g(there)g(is)h(no)f(immediate)i(error,)d (but)h(the)h(v)m(alue)g(of)0 1185 y(the)g(arra)o(y)f(at)g(that)g(index)i(is)g (then)f(unde\014ned,)i(so)d(that)h(subscripting)h(the)f(arra)o(y)f(with)h (suc)o(h)g(an)g(index)h(yields)0 1241 y(an)f(error.)0 1542 y Fg(9.3)56 b(Accum)n(ulation)0 1721 y Fp(W)l(e)14 b(can)g(relax)g(the)g (restriction)g(that)f(an)h(index)h(app)q(ear)f(at)g(most)f(once)h(in)g(the)g (asso)q(ciation)h(list)f(b)o(y)g(sp)q(ecifying)0 1777 y(ho)o(w)h(to)g(com)o (bine)h(m)o(ultiple)i(v)m(alues)f(asso)q(ciated)e(with)h(a)g(single)g(index;) h(the)f(result)g(is)g(called)h(an)f Fo(ac)n(cumulate)n(d)0 1834 y(arr)n(ay)p Fp(:)71 1943 y Fi(accumArray)22 b(::)i(\(Ix)f(a\))h(->)f (\(b)h(->)f(c)h(->)g(b\))f(->)h(b)g(->)f(\(a,a\))g(->)h([Assoc)f(a)h(c])f(->) h(Array)f(a)h(b)0 2054 y Fp(The)15 b(\014rst)g(argumen)o(t)g(of)g Fi(accumArray)e Fp(is)j(the)g Fo(ac)n(cumulating)g(function)p Fp(,)e(the)i(second)f(is)h(an)f(initial)j(v)m(alue)e(\(the)0 2111 y(same)g(for)f(eac)o(h)i(elemen)o(t)g(of)e(the)i(arra)o(y\),)d(and)i (the)h(remaining)g(argumen)o(ts)e(are)h(b)q(ounds)h(and)f(an)h(asso)q (ciation)0 2167 y(list,)e(as)f(with)h(the)g Fi(array)e Fp(function.)21 b(T)o(ypically)l(,)16 b(the)f(accum)o(ulating)g(function)g(is)g Fi(\(+\))p Fp(,)f(and)h(the)f(initial)j(v)m(alue,)0 2224 y(zero;)f(for)g (example,)h(this)f(function)h(tak)o(es)f(a)f(pair)i(of)f(b)q(ounds)h(and)f(a) g(list)h(of)f(v)m(alues)h(\(of)e(an)h(index)i(t)o(yp)q(e\))e(and)0 2280 y(yields)h(a)e(histogram;)f(that)g(is,)i(a)e(table)i(of)f(the)g(n)o(um)o (b)q(er)h(of)e(o)q(ccurrences)j(of)d(eac)o(h)i(v)m(alue)g(within)h(the)e(b)q (ounds:)71 2389 y Fi(hist)285 b(::)24 b(\(Ix)f(a,)h(Integral)f(b\))g(=>)h (\(a,a\))f(->)h([a])f(->)h(Array)f(a)h(b)71 2446 y(hist)f(bnds)g(is)95 b(=)48 b(accumArray)22 b(\(+\))i(0)g(bnds)f([i)h(:=)f(1)h(|)g(i)f(<-)h(is,)f (inRange)g(bnds)h(i])0 2557 y Fp(Supp)q(ose)c(w)o(e)e(ha)o(v)o(e)h(a)f (collection)j(of)d(measuremen)o(ts)h(on)g(the)f(in)o(terv)m(al)i([)p Fo(a)s Fh(;)8 b Fo(b)s Fp(\))o(,)20 b(and)f(w)o(e)f(w)o(an)o(t)g(to)g(divide) j(the)0 2614 y(in)o(terv)m(al)16 b(in)o(to)f(decades)h(and)g(coun)o(t)f(the)g (n)o(um)o(b)q(er)h(of)e(measuremen)o(ts)h(within)i(eac)o(h:)p eop %%Page: 51 51 bop 0 -40 a Fj(9.4)45 b(Incremen)o(tal)16 b(up)q(dates)1348 b Fp(T-51)71 160 y Fi(decades)213 b(::)24 b(\(RealFrac)f(a\))g(=>)h(a)g(->)f (a)h(->)f([a])h(->)f(Array)h(Int)f(Int)71 216 y(decades)f(a)i(b)119 b(=)48 b(hist)23 b(\(0,9\))g(.)h(map)g(decade)524 272 y(where)f(decade)g(x)h (=)g(floor)f(\(\(x)g(-)h(a\))g(*)f(s\))667 329 y(s)191 b(=)24 b(10)f(/)h(\(b)g(-)f(a\))0 572 y Fg(9.4)56 b(Incremen)n(tal)16 b(up)r(dates)0 691 y Fp(In)d(addition)g(to)e(the)i(monolithic)g(arra)o(y)e (creation)h(functions,)h(Hask)o(ell)g(also)f(has)g(an)g(incremen)o(tal)i (arra)o(y)c(up)q(date)0 747 y(function,)15 b(written)g(as)f(the)h(in\014x)g (op)q(erator)f Fi(//)p Fp(;)g(the)h(simplest)h(case,)e(an)h(arra)o(y)e Fi(a)h Fp(with)h(elemen)o(t)h Fi(i)e Fp(up)q(dated)i(to)0 804 y Fi(v)p Fp(,)e(is)i(written)e Fi(a)24 b(//)g([i)f(:=)h(v])p Fp(.)19 b(The)c(reason)g(for)f(the)g(square)h(brac)o(k)o(ets)f(is)h(that)f (the)h(left)g(argumen)o(t)f(of)h Fi(\(//\))0 860 y Fp(is)h(an)f(asso)q (ciation)g(list,)h(usually)h(con)o(taining)f(a)e(prop)q(er)i(subset)f(of)g (the)g(indices)j(of)c(the)i(arra)o(y:)71 969 y Fi(\(//\))285 b(::)24 b(\(Ix)f(a\))h(=>)g(Array)f(a)h(b)f(->)h([Assoc)f(a)h(b])f(->)h (Array)f(a)h(b)0 1078 y Fp(As)15 b(with)h(the)f Fi(array)g Fp(function,)h(the)f(indices)i(in)f(the)g(asso)q(ciation)g(list)g(m)o(ust)e (b)q(e)i(unique)h(for)e(the)g(v)m(alues)i(to)d(b)q(e)0 1135 y(de\014ned.)21 b(F)l(or)15 b(example,)g(here)h(is)g(a)f(function)h(to)e(in)o (terc)o(hange)i(t)o(w)o(o)e(ro)o(ws)g(of)h(a)f(matrix:)71 1243 y Fi(swapRows)22 b(::)i(\(Ix)f(a,)h(Ix)g(b,)f(Enum)g(b\))h(=>)g(a)f(->)h(a)g (->)f(Array)g(\(a,b\))h(c)f(->)h(Array)f(\(a,b\))g(c)71 1300 y(swapRows)f(i)i(i')g(a)f(=)48 b(a)24 b(//)f(\([\(i,j\))47 b(:=)24 b(a!\(i',j\))e(|)i(j)g(<-)f([jLo..jHi]])g(++)667 1356 y([\(i',j\))g(:=)h(a!\(i,)f(j\))g(|)h(j)g(<-)f([jLo..jHi]]\))524 1413 y(where)g(\(\(iLo,jLo\),\(iHi,jHi\)\))e(=)j(bounds)f(a)0 1522 y Fp(The)15 b(concatenation)f(here)h(of)g(t)o(w)o(o)e(separate)h(list)h (comprehensions)h(o)o(v)o(er)d(the)i(same)f(list)i(of)e Fi(j)g Fp(indices)j(is,)d(ho)o(w-)0 1578 y(ev)o(er,)i(a)h(sligh)o(t)g (ine\016ciency;)i(it's)d(lik)o(e)i(writing)f(t)o(w)o(o)e(lo)q(ops)i(where)g (one)f(will)i(do)f(in)g(an)g(imp)q(erativ)o(e)g(language.)0 1635 y(Nev)o(er)e(fear,)g(w)o(e)f(can)i(p)q(erform)f(the)g(equiv)m(alen)o(t)i (of)e(a)g(lo)q(op)g(fusion)h(optimization)g(in)g(Hask)o(ell:)71 1744 y Fi(swapRows)22 b(i)i(i')g(a)f(=)48 b(a)24 b(//)f([assoc)g(|)h(j)g(<-)f ([jLo..jHi],)858 1800 y(assoc)g(<-)h([\(i,)f(j\))h(:=)f(a!\(i',j\),)1097 1857 y(\(i',j\))g(:=)g(a!\(i,)h(j\)])f(])524 1913 y(where)g (\(\(iLo,jLo\),\(iHi,jHi\)\))e(=)j(bounds)f(a)0 2156 y Fg(9.5)56 b(An)19 b(example:)j(Matrix)c(Multiplication)0 2275 y Fp(W)l(e)13 b(complete)h(our)f(in)o(tro)q(duction)h(to)e(Hask)o(ell)i(arra)o(ys)e(with)h (the)g(familiar)h(example)g(of)e(matrix)h(m)o(ultiplication,)0 2331 y(taking)k(adv)m(an)o(tage)f(of)g(o)o(v)o(erloading)h(to)f(de\014ne)i(a) e(fairly)i(general)f(function.)25 b(Since)18 b(only)g(m)o(ultiplication)h (and)0 2388 y(addition)c(on)f(the)f(elemen)o(t)i(t)o(yp)q(e)f(of)f(the)h (matrices)g(is)g(in)o(v)o(olv)o(ed,)h(w)o(e)e(get)h(a)f(function)i(that)e(m)o (ultiplies)j(matrices)0 2444 y(of)h(an)o(y)g(n)o(umeric)h(t)o(yp)q(e)g (unless)h(w)o(e)e(try)g(hard)g(not)g(to.)26 b(Additionally)l(,)20 b(if)e(w)o(e)f(are)g(careful)h(to)f(apply)h(only)g Fi(\(!\))0 2501 y Fp(and)f(the)h(op)q(erations)f(of)g Fi(Ix)g Fp(to)g(indices,)i(w)o(e)e (get)g(genericit)o(y)h(o)o(v)o(er)e(index)j(t)o(yp)q(es,)e(and)h(in)g(fact,)f (the)g(four)g(ro)o(w)0 2557 y(and)e(column)h(index)f(t)o(yp)q(es)g(need)h (not)e(all)i(b)q(e)f(the)g(same.)k(F)l(or)14 b(simplicit)o(y)l(,)j(ho)o(w)o (ev)o(er,)d(w)o(e)g(require)i(that)e(the)h(left)0 2614 y(column)g(indices)g (and)f(righ)o(t)g(ro)o(w)e(indices)k(b)q(e)f(of)e(the)h(same)f(t)o(yp)q(e,)h (and)g(moreo)o(v)o(er,)e(that)h(the)h(b)q(ounds)g(b)q(e)h(equal:)p eop %%Page: 52 52 bop 0 -40 a Fp(T-52)1597 b Fj(9)45 b(ARRA)l(YS)71 160 y Fi(matMult)213 b(::)24 b(\(Ix)f(a,)h(Ix)g(b,)f(Ix)h(c,)f(Num)h(d\))f(=>)524 216 y(Array)g(\(a,b\))g(d)h(->)g(Array)f(\(b,c\))g(d)h(->)f(Array)h(\(a,c\))f (d)71 272 y(matMult)f(x)i(y)119 b(=)48 b(array)23 b(resultBounds)667 329 y([\(i,j\))g(:=)h(sum)f([x!\(i,k\))g(*)h(y!\(k,j\))f(|)g(k)h(<-)g(range)f (\(lj,uj\)])1025 385 y(|)h(i)g(<-)f(range)g(\(li,ui\),)1073 442 y(j)h(<-)f(range)g(\(lj',uj'\))g(])261 498 y(where)h (\(\(li,lj\),\(ui,uj\)\))212 b(=)48 b(bounds)23 b(x)405 555 y(\(\(li',lj'\),\(ui',uj'\)\))116 b(=)48 b(bounds)23 b(y)405 611 y(resultBounds)452 668 y(|)h(\(lj,uj\)==\(li',ui'\))93 b(=)48 b(\(\(li,lj'\),\(ui,uj'\)\))452 724 y(|)24 b(otherwise)309 b(=)24 b(error)f("matMult:)g(incompatible)f(bounds")0 833 y Fp(As)16 b(an)h(aside,)g(w)o(e)f(can)g(also)h(de\014ne)g Fi(matMult)f Fp(using)h Fi(accumArray)n Fp(,)g(resulting)g(in)g(a)f(presen)o(tation)h (that)e(more)0 890 y(closely)h(resem)o(bles)g(the)g(usual)g(form)o(ulation)f (in)h(an)f(imp)q(erativ)o(e)h(language:)71 999 y Fi(matMult)22 b(x)i(y)119 b(=)48 b(accumArray)22 b(\(+\))i(0)g(resultBounds)786 1055 y([\(i,j\))g(:=)f(x!\(i,k\))g(*)h(y!\(k,j\))977 1112 y(|)g(i)g(<-)f (range)h(\(li,ui\),)1025 1168 y(j)g(<-)f(range)h(\(lj',uj'\))1025 1224 y(k)g(<-)f(range)h(\(lj,uj\))46 b(])261 1281 y(where)24 b(\(\(li,lj\),\(ui,uj\)\))212 b(=)48 b(bounds)23 b(x)405 1337 y(\(\(li',lj'\),\(ui',uj'\)\))116 b(=)48 b(bounds)23 b(y)405 1394 y(resultBounds)452 1450 y(|)h(\(lj,uj\)==\(li',ui'\))93 b(=)48 b(\(\(li,lj'\),\(ui,uj'\)\))452 1507 y(|)24 b(otherwise)309 b(=)24 b(error)f("matMult:)g(incompatible)f(bounds")71 1718 y Fp(W)l(e)16 b(can)h(generalize)h(further)e(b)o(y)h(making)g(the)f(function) i(higher-order,)f(simply)h(replacing)g Fi(sum)e Fp(and)g Fi(\(*\))0 1775 y Fp(b)o(y)f(functional)i(parameters:)71 1883 y Fi(genMatMult)141 b(::)24 b(\(Ix)f(a,)h(Ix)g(b,)f(Ix)h(c\))f(=>)524 1940 y(\([f])g(->)h(g\))f (->)h(\(d)g(->)f(e)h(->)g(f\))f(->)524 1996 y(Array)g(\(a,b\))g(d)h(->)g (Array)f(\(b,c\))g(e)h(->)f(Array)h(\(a,c\))f(g)71 2053 y(genMatMult)f(f)i(g) g(x)f(y)48 b(=)f(array)24 b(resultBounds)643 2109 y([\(i,j\))f(:=)h(f)g ([x!\(i,k\))e(`g`)i(y!\(k,j\))f(|)h(k)f(<-)h(range)f(\(lj,uj\)])858 2166 y(|)h(i)g(<-)f(range)g(\(li,ui\),)906 2222 y(j)h(<-)f(range)g (\(lj',uj'\))g(])261 2279 y(where)h(\(\(li,lj\),\(ui,uj\)\))212 b(=)48 b(bounds)23 b(x)405 2335 y(\(\(li',lj'\),\(ui',uj'\)\))116 b(=)48 b(bounds)23 b(y)405 2392 y(resultBounds)452 2448 y(|)h (\(lj,uj\)==\(li',ui'\))93 b(=)48 b(\(\(li,lj'\),\(ui,uj'\)\))452 2504 y(|)24 b(otherwise)309 b(=)24 b(error)f("matMult:)g(incompatible)f (bounds")0 2614 y Fp(APL)16 b(fans)f(will)h(recognize)g(the)g(usefulness)g (of)f(functions)h(lik)o(e)g(the)g(follo)o(wing:)p eop %%Page: 53 53 bop 1857 -40 a Fp(T-53)71 160 y Fi(genMatMult)22 b(maximum)h(\(-\))71 216 y(genMatMult)f(and)i(\(==\))0 328 y Fp(With)15 b(the)g(\014rst)f(of)g (these,)h(the)g(argumen)o(ts)f(are)g(n)o(umeric)i(matrices,)e(and)h(the)g(\() p Fo(i)5 b Fh(;)j Fo(j)f Fp(\))m(-th)15 b(elemen)o(t)g(of)g(the)g(result)0 384 y(is)g(the)g(maxim)o(um)f(di\013erence)i(b)q(et)o(w)o(een)f(corresp)q (onding)h(elemen)o(ts)f(of)f(the)h Fo(i)5 b Fp(-th)14 b(ro)o(w)g(and)h Fo(j)6 b Fp(-th)15 b(column)h(of)e(the)0 441 y(inputs.)30 b(In)18 b(the)h(second)f(case,)h(the)f(argumen)o(ts)f(are)h(matrices)g(of)g(an)o(y)g (equalit)o(y)h(t)o(yp)q(e,)f(and)h(the)f(result)h(is)f(a)0 497 y(Bo)q(olean)d(matrix)f(in)h(whic)o(h)g(elemen)o(t)g(\()p Fo(i)5 b Fh(;)j Fo(j)f Fp(\))k(is)k Fi(True)f Fp(if)g(and)h(only)g(if)f(the)g Fo(i)5 b Fp(-th)14 b(ro)o(w)g(of)f(the)i(\014rst)e(argumen)o(t)h(and)0 553 y Fo(j)7 b Fp(-th)15 b(column)h(of)f(the)g(second)h(are)e(equal)i(as)f(v) o(ectors.)71 629 y(Notice)k(that)f(the)h(elemen)o(t)g(t)o(yp)q(es)g(of)g Fi(genMatMult)e Fp(need)j(not)e(b)q(e)i(the)e(same,)i(but)e(merely)i (appropriate)0 685 y(for)c(the)i(function)f(parameter)g Fi(g)p Fp(.)25 b(W)l(e)17 b(could)h(generalize)h(still)f(further)f(b)o(y)g(dropping) h(the)f(requiremen)o(t)h(that)0 742 y(the)i(\014rst)f(column)i(index)f(and)g (second)g(ro)o(w)f(index)i(t)o(yp)q(es)f(b)q(e)g(the)g(same;)h(clearly)l(,)h (t)o(w)o(o)c(matrices)i(could)g(b)q(e)0 798 y(considered)14 b(conformable)g(as)e(long)i(as)e(the)i(lengths)f(of)g(the)g(columns)h(of)e (the)i(\014rst)e(and)i(the)f(ro)o(ws)f(of)g(the)h(second)0 855 y(are)k(equal.)28 b(The)18 b(reader)g(ma)o(y)f(wish)h(to)f(deriv)o(e)h (this)h(still)g(more)e(general)h(v)o(ersion.)27 b(\()p Fc(Hin)o(t:)e Fp(Use)18 b(the)g Fi(index)0 911 y Fp(op)q(eration)d(to)g(determine)h(the)f (lengths.\))0 1070 y Fq(10)69 b(Ac)n(kno)n(wledgemen)n(ts)0 1190 y Fp(Thanks)20 b(to)g(P)o(atricia)h(F)l(asel)f(and)h(Mark)f(Mundt)g(at)g (Los)g(Alamos,)i(and)e(Nic)o(k)h(Carriero,)g(Charles)g(Consel,)0 1247 y(Amir)f(Kishon,)h(Sandra)e(Lo)q(osemore,)h(Martin)f(Odersky)l(,)h(John) g(P)o(eterson,)g(and)f(Da)o(vid)h(Ro)q(c)o(h)o(b)q(erg)f(at)g(Y)l(ale)0 1303 y(Univ)o(ersit)o(y)i(for)f(their)g(quic)o(k)i(readings)e(of)g(earlier)h (drafts)f(of)g(this)h(man)o(uscript.)35 b(Sp)q(ecial)23 b(thanks)d(to)f(John) 0 1360 y(P)o(eterson)c(for)f(getting)h(the)h(bugs)f(out)g(of)f(our)h(Hask)o (ell)h(co)q(de.)0 1519 y Fq(References)0 1636 y Fp([1])22 b(R.)d(Bird)h(and)f (P)l(.)g(W)l(adler.)32 b Fo(Intr)n(o)n(duction)19 b(to)h(F)m(unctional)f(Pr)n (o)n(gr)n(amming)p Fp(.)31 b(Pren)o(tice)20 b(Hall,)g(New)g(Y)l(ork,)71 1692 y(1988.)0 1780 y([2])i(P)l(.)14 b(Hudak.)20 b(Conception,)c(ev)o (olution,)f(and)g(application)i(of)e(functional)h(programming)e(languages.)20 b Fo(A)o(CM)71 1836 y(Computing)c(Surveys)p Fp(,)e(21\(3\):359{411,)d(1989.)0 1924 y([3])22 b(P)l(.)c(Hudak,)h(S.)f(P)o(eyton)f(Jones,)i(and)g(P)l(.)f(W)l (adler)g(\(editors\).)29 b(Rep)q(ort)18 b(on)g(the)h(Programming)e(Language) 71 1981 y(Hask)o(ell,)23 b(A)e(Non-strict)g(Purely)h(Functional)g(Language)f (\(Version)g(1.2\).)36 b Fo(A)o(CM)20 b(SIGPLAN)g(Notic)n(es)p Fp(,)71 2037 y(27\(5\),)13 b(Ma)o(y)h(1992.)0 2125 y([4])22 b(R.S.)c(Nikhil.)30 b(Id)18 b(\(v)o(ersion)g(90.0\))f(reference)h(man)o(ual.) 29 b(T)l(ec)o(hnical)19 b(rep)q(ort,)f(Massac)o(h)o(usetts)f(Institute)h(of) 71 2181 y(T)l(ec)o(hnology)l(,)d(Lab)q(oratory)f(for)h(Computer)g(Science,)i (Septem)o(b)q(er)e(1990.)0 2269 y([5])22 b(J.)15 b(Rees)h(and)g(W.)f(Clinger) h(\(eds.\).)k(The)c(revised)928 2252 y Fm(3)964 2269 y Fp(rep)q(ort)f(on)h (the)f(algorithmic)h(language)g(Sc)o(heme.)21 b Fo(SIG-)71 2325 y(PLAN)15 b(Notic)n(es)p Fp(,)f(21\(12\):37{79)o(,)e(Decem)o(b)q(er)k (1986.)0 2413 y([6])22 b(G.L.)14 b(Steele)j(Jr.)i Fo(Common)e(Lisp:)j(The)c (L)n(anguage)p Fp(.)j(Digital)d(Press,)e(Burlington,)i(Mass.,)e(1984.)0 2501 y([7])22 b(P)l(.)f(W)l(adler.)39 b(Ho)o(w)21 b(to)g(replace)i(failure)g (b)o(y)e(a)h(list)g(of)f(successes.)40 b(In)22 b Fo(Pr)n(o)n(c)n(e)n(e)n (dings)e(of)i(Confer)n(enc)n(e)e(on)71 2557 y(F)m(unctional)e(Pr)n(o)n(gr)n (amming)h(L)n(anguages)g(and)h(Computer)h(A)o(r)n(chite)n(ctur)n(e,)f(LNCS)e (V)m(ol.)h(201)p Fp(,)h(pages)f(113{)71 2614 y(128.)14 b(Springer)i(V)l (erlag,)f(1985.)p eop %%Trailer end userdict /end-hook known{end-hook}if %%EOF