A -E : a Haskell Tutor SK LLE Proefschrift terverkrijgingvandegraadvandoctor aandeOpenUniversiteit opgezagvanderectormagnificus prof.mr.A.Oskamp tenoverstaanvaneendoorhet Collegevoorpromotiesingesteldecommissie inhetopenbaarteverdedigen opvrijdag23november2012teHeerlen om13:30uurprecies door Alex Gerdes geborenop10juli1978teEmmen Promotor Prof. dr. J.Th. Jeuring OpenUniversiteit UniversiteitUtrecht Overigeledenbeoordelingscommissie Prof. dr. dr.h.c. ir. M.J.Plasmeijer RadboudUniversiteit Prof. dr. S.D.Swierstra UniversiteitUtrecht Prof. dr. S.J.Thompson UniversityofKent Prof. dr. M.C.J.D.vanEekelen OpenUniversiteit RadboudUniversiteit Prof. dr. ir. S.M.M.Joosten OpenUniversiteit PrintedbyGildeprintdrukkerijen,Enschede. CoverbyPeterGerdes. ISBN978-94-6108-371-5 ©AlexGerdes,2012 CONTENTS 1 Introduction 1 1.1 ASK-ELLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.2 Relatedworkonprogrammingtutors . . . . . . . . . . . . . . . . . 7 1.3 Structureofthisthesis . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.4 Originofchapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 I Domainreasoners 13 2 Strategies 15 2.1 Strategiesandfeedback. . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.2 Examplestrategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.3 Alanguageforstrategiesforexercises . . . . . . . . . . . . . . . . . 22 2.4 Strategyfunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.5 Feedbackbasedonstrategies . . . . . . . . . . . . . . . . . . . . . . 41 2.6 Relatedworkonstrategies . . . . . . . . . . . . . . . . . . . . . . . . 43 3 Astrategyrecogniser 45 3.1 Representinggrammars . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.2 Dealingwithlabels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 3.3 Smartconstructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 iii Contents 3.4 Runningastrategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 3.5 Tracingastrategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4 Exercises 57 4.1 Strategyandrules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.2 Syntacticandsemanticchecks . . . . . . . . . . . . . . . . . . . . . . 66 4.3 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5 Domainreasoners 73 5.1 Feedbackservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.2 Webservices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.3 Feedbackscripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 II HaskellTutor 87 6 AprogrammingtutorforHaskell 89 6.1 Programmingtutoroverview . . . . . . . . . . . . . . . . . . . . . . 91 6.2 Domaindescription . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 6.3 Testingincompleteprograms . . . . . . . . . . . . . . . . . . . . . . 96 6.4 Aninteractivesession . . . . . . . . . . . . . . . . . . . . . . . . . . 97 6.5 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 7 Specifyingprogrammingexercises 109 7.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 7.2 Feedbackscriptsforprogrammingexercises. . . . . . . . . . . . . . 111 7.3 Annotatingmodelsolutions . . . . . . . . . . . . . . . . . . . . . . . 111 8 Constructingprogrammingstrategies 115 8.1 Refinementrules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 8.2 Focusingrefinementrules . . . . . . . . . . . . . . . . . . . . . . . . 120 8.3 Strategiesinfunctionalprogramming . . . . . . . . . . . . . . . . . 123 8.4 Derivingprogrammingstrategies . . . . . . . . . . . . . . . . . . . . 125 9 AcanonicalformforHaskellprograms 129 9.1 Programtransformations. . . . . . . . . . . . . . . . . . . . . . . . . 130 9.2 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 10 Aprogrammingstrategyrecogniser 135 10.1 Paralleltop-downrecogniser . . . . . . . . . . . . . . . . . . . . . . 136 10.2 Searchspacereduction . . . . . . . . . . . . . . . . . . . . . . . . . . 137 iv Contents 11 AssessingHaskellprograms 143 11.1 Usingourassessmenttool . . . . . . . . . . . . . . . . . . . . . . . . 145 11.2 Relatedworkonassessment . . . . . . . . . . . . . . . . . . . . . . . 148 12 Epilogueandfuturework 151 12.1 Futurework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Samenvatting 157 Curriculumvitae 163 Listofacronyms 177 Index 178 v Acknowledgements ThelastfiveyearsIparticipatedasa‘promovendus’inaongoingresearchproject ongeneratingsemanticallyrichfeedback. Ithoroughlyenjoyedthisperiod,and neverregrettedthedecisionoftakingthisacademicjob. Itinvolvedhardwork, alotoftravelling,manyinterestingdiscussions,andmuchcoding. Togetherthis culminatedinthisthesis. DuringmyresearchIreceivedhelpfrommanypeople, forwhichIamverygrateful. FirstofallIwouldliketothankmypromotorJohanJeuring,whomIowevery much. Youhavealwaysbeenverythoroughandprecisewhenreviewingmywork, andguidedmeintotherightdirectionwhenneeded. Youalwayshadtimeforme, evenwhenyoumovedtoSwedenforawhile. Youconstantlypushedmetodo better. Thatwasnotalwayseasy,butIvalueitverymuch. Johan,Iamverylucky tohavehadyouasmysupervisor;Icouldnothavewishedforabetterone! Iwouldalsoliketothankthemembersoftheexaminationcommittee(Markovan Eekelen,StefJoosten,RinusPlasmeijer,DoaitseSwierstra,andSimonThompson) forreadingandapprovingthemanuscript,andprovidingmewithseveraluseful comments. Also,IwouldliketothankBastiaanHeerenforthemanydiscussionswehad aboutourresearchandtheimplementationofoursoftware. Ilearnedalotfrom thosediscussions;youareagiftedprogrammer. Furthermore,Iwouldliketothank LexBijlsmaforbeingtheperfectline-manager,yourresponsetimeislegendary. A bigthankyougoestoChrisjaMuris,HarriePassier,SylviaStuurman,JosjeLodder, andtheothercolleaguesattheOpenUniversity. Youmademytimeworkingin Heerlenveryenjoyable. IamthankfulforDoaitseSwierstraandtheUtrechtUniversityforhavingmeas guestduringmyPhD-study. TheSoftwareTechnologygroupisaveryinspiring environment and an excellent place to do research. I would like to thank José PedroMagalhães,SeanLeather,AndresLöh,WouterSwierstra,StefanHoldermans, ArieMiddelkoop,JurriaanHage,AlexeyRodriguezYakushev,andalltheother colleagues for the really nice time I had in Utrecht. I would also like to thank myroommate(and‘lotgenoot’)ThomasvanNoort. AnotherthanksgoestoBram SchuurandBramVaessenforassistingmewiththeexperiments. IhadthepleasureofmeetingMarySheeranattheCentralEuropeanFunctional Programmingsummerschool2011inBudapest. Thismeetingeventuallyledtoa dreamjobatQuviQinGöteborg. MaryIcan’tthankyouenoughforthat! Iwould alsoliketothankThomasArts,JohnHughes,UlfNorell,andHansSvensson(my new colleagues at QuviQ) for the warm welcome. You have made the move to Swedenalotlessdifficult. Tacksåjättemycket! Finally,IwouldliketothankmyparentsRudieandWilly,mysisterMarloes,my brotherPeter(whowaskindenoughtodesignthebeautifulcoverofthisthesis), vii Acknowledgements myparentsinlawHillieandHarm,andtherestofmyfamilyandfriendsfortheir support,understanding,andtime. John,Jos,andGosé,Iamgratefulthatyouare myfriends. EspeciallyIwouldliketothankmywifeAnitaandmychildrenMats, Lise,andSofie–youmakeitallworthwhile. Anita,thankyouforwhoyouare; you’llneverknowtheextentofmygratitude! AlexGerdes Herrljunga,Autumn2012 viii
Description: