The lambdas must flow. If I break, you can: 1. Restart: M-x haskell-process-restart 2. Configure logging: C-h v haskell-process-log (useful for debugging) 3. General config: M-x customize-mode 4. Hide these tips: C-h v haskell-process-show-debug-tips Changed directory: /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/ λ> x 1 λ> :r Ok, one module loaded. λ> :r [1 of 1] Compiling Aula9 ( /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula9.hs, interpreted ) Ok, one module loaded. Collecting type info for 1 module(s) ... λ> x 4 λ> :t x x :: Integer λ> :t f f :: Integer -> Integer λ> :t g g :: Integer -> Integer λ> :t h h :: Num a => p -> a λ> h "Hugo" 3 λ> h True 3 λ> :t 3 3 :: Num a => a λ> f 6 36 λ> f (6) 36 λ> (f 6) 36 λ> f6 :29:1-2: error: * Variable not in scope: f6 * Perhaps you meant `f' (line 7) λ> f f 6 :30:1-5: error: * Couldn't match expected type `t0 -> t' with actual type `Integer' * The function `f' is applied to two value arguments, but its type `Integer -> Integer' has only one In the expression: f f 6 In an equation for `it': it = f f 6 * Relevant bindings include it :: t (bound at :30:1) :30:3: error: * Couldn't match expected type `Integer' with actual type `Integer -> Integer' * Probable cause: `f' is applied to too few arguments In the first argument of `f', namely `f' In the expression: f f 6 In an equation for `it': it = f f 6 λ> :t (f 6) (f 6) :: Integer λ> f (f 6) 1296 λ> f $ f 6 1296 λ> f $ f $ f 6 1679616 λ> 1296^2 1679616 λ> fun 10 15 150 λ> fun (10 15) :39:1-11: error: * Could not deduce (Num t0) arising from a type ambiguity check for the inferred type for `it' from the context: (Num a, Num t, Num (t -> a)) bound by the inferred type for `it': forall {a} {t}. (Num a, Num t, Num (t -> a)) => a -> a at :39:1-11 The type variable `t0' is ambiguous These potential instances exist: instance Num Integer -- Defined in `GHC.Num' instance Num Double -- Defined in `GHC.Float' instance Num Float -- Defined in `GHC.Float' ...plus two others ...plus two instances involving out-of-scope types (use -fprint-potential-instances to see them all) * In the ambiguity check for the inferred type for `it' To defer the ambiguity check to use sites, enable AllowAmbiguousTypes When checking the inferred type it :: forall {a} {t}. (Num a, Num t, Num (t -> a)) => a -> a λ> fun (10, 15) fun (10, 15) :: (Num a, Num b, Num (a, b)) => (a, b) -> (a, b) λ> fun2 15 150 λ> fun (10,15) :45:5-11: error: * Couldn't match expected type `Integer' with actual type `(a0, b0)' * In the first argument of `fun', namely `(10, 15)' In the expression: fun (10, 15) In an equation for `it': it = fun (10, 15) λ> fun3 60 fun3 60 :: Integer -> Integer λ> fun3 50 70 3500 λ> fun4 "Hugo" 36 λ> fun4 "João" 60 λ> fibo 5 5 λ> fibo 50 Interrupted. λ> fibo_magico !! 50 12586269025 λ> fibo_magico !! 8 21 λ> fibo 20 6765 λ> fibo_magico !! 125 59425114757512643212875125 λ> fibo_magico !! 125324324 Interrupted. λ> fibo_magico !! 12532432fibo_magico !! 12532432Interrupted. λ> fibo_magico !! 12532432 Interrupted. λ> fibo_magico !! 1253243fibo_magico !! 125324Interrupted. λ> fibo_magico !! 125324 6569641727777725611934249132496562804495864443160189893761209447823761227666796217691305468790120383660191401922084378095073051706212325692465250610080725481147298108847105714089806797816949271681586770881247294686326122991965450206863258974369578169564903355913909058853446757850932051434913904531122256845560615232001080561933507902485753692983895441496448848260269778840614500221912306685869032549258614826306594503436093356609990788180343412779642492430281709603669400572805484289321736223821736089363835576855547802223930760620335500569392133668325422603470248168463945700028565751429179245657406851365593231481544608667721006046810545719903283841859937539154239345077303327080312541951849577802660928654534104265818760341107202302035038646335164783214093263418807211227169799403894642028889084443823560250248934890028277494619943572894988667970726311708303569160301979188811999685085046252315645194384770330438687329796333025904212059186610276374913358100783137889961373957779047563377876224409909673399677786410857929760502356064502448827472384950669749018495037650944465289525923135482042592207961705401087162533369893953279516629816784813687535961885846861774792312261162643267158613379157199252450177889121630606519336361756408496427085310369821672793694665491043433098511591030018195909970969817787247403937026172173134773449915129138262838307929151774152842150959891955922939277003188708213462969778142063666743308845772285441010728648599919808236333665855267182087219289206504851293547360499089587963089934205657827126429481808172031054893612364394049836945252699391899548428178577622542169248023103028894877273464798878426264400332962568338698233794398059034731505830010916945272489287980455494195305282833177969488831727856170502013127810423171261375497662334174083586294530396146339082921751603482353443535450648334302082321059063048723393224190496346116200800362933517124525371569856608189480887531922156248131751414911739806331354266367372777096165858619554925956210349316521811634720438524155682191125165669331725352538775794420319163086323325072477626882596316464369004103536480334581847149418130549682297419357142606447879455875761731356341258034805360172562939520940436687333201009666500261764435052048286499969053353521651109628537217765928547853334802332739753800957151699779444322472891182457799375595291647142486667667537583222707929138781350190098994386278713522461020602182297200144225632064132883717458385066867465395632179197297319874960606579155785642965553371572479437448193981698660893015722762218737240150843591599693836955267521355987859291663207267716642674137839918045892067995310240504931687360719776422808204001284110354863737350158795503293379356268360501452732031126000590359691142910935389866527945496293012793904427790254511894407565989602157308837629911776414788438489255905731943761800963219559753463774500643257897808553031670311589039058031080771646147463264131252854162067740534462904540807020096130764984188062359382574428544020081338883617624445106817952025843437541130052989408303392959322271610747898774094351302337391182025195934387112814907409799420559160453811165907491215191900411914963806763587339043076855699710305145067434288511536257683734222718934861345019881381422524794853060102220873198709305893991189044361500415141849569373174649716275819943067131483897131495635868290285990732758085671788667765274476525649811123590201076492394887874396726109613238809248554457626845741024132993209342059933610723169962918658097981579023969886886059611222638845139551211238169994409345975578530532349065514950096399840855548298572105743573883081433879546681289512069466747706375174858093932516424549001345075497898372205295325475622128255459261626012743219370969815974977745449335131347913878733652360657964795824356310880065418811513589167933317076876761623505708350903588312591928119158066107587278271156663109182409347856383815920452178031379339027413559644691336134979138084706651911435698215688709493544047120317928419501600204013340195337113703313522737221031554756546499793221965250337910482820477809910732022580475497951892780362643141282294555299361011475357957478002898886939266852589496982115093054519253046769840035075283492042953754613098727538829881164243117170765112080084047149135839191073748586720081340298819155197218869618334313538280216914049041940882048457832808099653611082583237691338876256182843248029810686500641407345164279108155331187089558413152619725915340202669640660418802429754029895588632615544869152419615851338457376635722979430034194334523527985883032181028986504726771818653599255055901446768013280681889245974966024594146042558999299492369069924477794780962650872632319866099496734221081654012463006245651266024499987160669452776896141412466723906930728597211802109486189316354983583443922416785594326612276010987038566312057114441294771432521493911899893645519676051577259016429908638210291413708936474111238393473944573128917691926132105511787627843708939816141082172636552732315995519471350883358638056566977871258892851987473951734981841515444905959614449826220691155951318634606065763701196063297781560144638354605139908129205951332106339139693635032533341261083330766238108164092220849696172289193236186709399604123398211797146272077648828339950102791941114095377572055428930020518769142439921903429794449678712693532958229506227975246355195862911359141691369743785644543577007693541880463576880412742667788076769724281992895732972785720194137378529873138186500910013940494868547510504247891992690944376790343002724986818432347540123727472897376385633966308763789692850698995197874698969323163077665590841701331598549666064222710197085129136567744981505567871340209865902206569343850596325950369521812850810159359148733734486788244936902303303656761570624112772826818796173339482207515441750577136103110229506374548968471171378607592294265277585707990505135789151454890960008362313409745710062973461082829047605037103220203608843074082258693569473498640945715514193324630755684064164696646704207682645989442482217479646510431532777478899131865658922231170022816052756793845446101819643047548480428401238876943062476010628645367841080893950045179796224001760751203498991108243721234154299546526649945368982003707814975649844188571304213510057376099847610774510052638350002300221167169789504722193150295057027959317305139861989843442286135881987078370261780544605586017790611848238273888902566022428848986776792180804956021207141822696627742909105094603382875853286773290012053012427539218268375926055986406695077191228745179209290361193556860625274144037805796015074471969430927964300290523241350023144698371161955063353092955340605093393325374852926375943592256392912235031849843085981785718186956911631753741414748084218885748032733146154069303758419428821039171368391481451910358600713350846526328834867753314409453015710864334264123026379622116098206463976718205482637789276254949560749683151107676751293864703602085190721912804570704635294182595051767953092934920062393439307639787079634976335225084774698061374409311571774901730956997433714700291244056499899546698675831085784756333121362880884194158817819625589514423690200878600254081256236385320918458969964662698037861071397280297529799683163786810295405643271105372951869647736426395400882276214828891438692572728974998203138966335820371092170779130312813881517219199178255120570572617753628974576538342659876990477037093525909899432885986245364681416398894730131697746520335039684247904964805012332911914333041398675425090343471436389824249649794580835905338990217379185279298656241145584110638924237710408501606430119890826579636681812945017105402818669645591211256337142996131584757494968770367690982217743131456388546728166827701624934735706694635177090824611891520644571641259107780252324691199640895552285598061074870369509286190712270113845305608149763277577103985420934948019670029398309970281115224692366295304764943103629987896737901694512378118210230797610809682607099379928244841823464456895662324744818418021306629590555816890151938657540079721167142150645440360842190227995053607227894480922802149002861564123600498993665365115717630392637881924407627179223564094881438967574339444040769246914646413121644075623845907428460961665351059737229003620972328158846053305101044488697108201897871271693898412850132541696760459197759652736138025308588198802628234966290471808709575683325669505636238842611615711494954643246412689055952228977569423328991019607586039222868365728515686084354787478048038017443060144112819159735151778780724756916281484919007900164915499740014803527288871128398380906570852243866154486528123527484182460645626123648548377340320802733404521371392390033047981900273261461135259908979414201304611847069463466124975797363750224989720914989529561412586289484901760117732611521416531934388493920840368064896361636475387820814842902107033455657639063401475302209803417840717575486140821085264898715814570341548032167330228231407057632617695017612885365549086418894098857936573971835826591954423036892302437790259187753156713766710006880754514262722139838355410594770200142002818006727993031723804999339117823426564878940608235157644527860583908595391767169146211389757857002570674570877345092779099307764546547113674133877158079468524350944807521830675486486539198635932010730148068717327861506077116231134618233185141142888038202832883325515067051938380169423188661822226206760437399368760036844253902126083614714442901214843533944133772787736028178103760649099813762515402896475616139439533173518595618788397616616554710621602048303257611402881883232097676074600018774435079003175937653928885189160972947898921280133466489668935097737188057310946769518462689648323579184076818842902248834027097750154404102255949376039317535408120920995718466312100910260281302719191379023057687143070364499188436812381399953687814644863356921896109488664569813146349095073825781612549156424063207602030329428722192585272354953553145806685772051779260538224856345093744125153481559336400648012380253584949214674285898658980151480017385052038128312515394112627172372462089385526721946963905548171103530079214057919451554494159662880956607859369097464922969725904904111828102561622693635073223694750066817162765415733288335688901528749575588503025273328553786147974930662093276836890125951373352897948287921781415794541821071236996935206218061912964093639513575763421555340563149881294298384432331794840880091462761357015486736610607358669734867793999407415095359413153116922637699283107718564659899772705598722572975854341675629215617834846200449175560390462450766701531985855870138003700829998699227729133989582083428960139221487005797719723536039098900598310096821455234386607671191963405545510779819786596313172596971664957887749070734391445961324067192425214895205295928859116925037903332893546330516085694461250078098483863285780428507768603228949919190289494066639978052682457611206921223830368943781715569098002809286221792442835944952049932763100499645156321623112889698286096590619946670862813614091675890198516040667093093129417779677713166692989048849447545294000707064171334552357448582185249263522762532789889721777895283317295884948283984812932793601591580047867331453746307519694338055164302931121614980359822059746550273895155245944451678997230738261097048610681544694881306000502715193339478706238354414069058093054528993409420018938894235966226852496253888523409875955800723878214350836846122187593982045133828676044298429082914350878071420834274228333885012769878227325587017609847048127070980459515182537520733761097747850552123129111044249892334214399023617041908451683365134294503005040133842586237525714351643606109921491597609815897416098442732542317226202065060592820350193627418044776320754287292606490290201085342311219105357930176053614905438954885555750887814761154490164832736912013765621432594984037508381825997117498222234335945844777062535231060826402975650999512748170587866643268240694098232440197752123890115291592915953778861206756765732325613664221237493919660688685888801608548414326328744345833719076753733584664154937997456157148958878356563147265947480950203694371622945639076618517444775140853131906792761094918436191947180964854785182420920535974510775009730647597670538666015242752342714456974995040143329645402547201375474512156090947320095527513062946749270027234941331213173700656108095063419545788181067375950691188723085528053148537466330393957481969222964016902396521826749458212165928531373101223588546477377910016404227042404202798938144580953857797102367983349284393156614545422735078887126135761572580429611753398357650765284292758466123737591615330075621990290163017809470674544913663553564907586212042036762595658682976868210562493408465936053077699153542668339162947825266667829998673866275241618626637052523480548837252794952160228816296393593357358125320149792703021507217896057661881660377792688820926987464440977909736399740244850562269017945692365114901536927054788054128264744759972410140845563748185082943176203033034875574204696467886235762862010687437050601406396123569125422261338532964664267519028607590532436655699145983702196306137417203534960273950851415621136889688289221573901254885728809246861424370264689409631213725420225157291928841435465931941955139552658995471087103484563383340029117848457423607413039957521510931306885111342797096348826268303548336044701249530443220123299016927347234115235876782740955394806445770151343883733362896470403567877528771109811440660861348896251625646353442364037197512088636520811249608399703654492208103794085566212172392583424540861955002039975948111686815617664693588365033635475126939818888105117099869116120705231620195163641530573729744212407764332973962873947652064248704866777217865884691653079491478565968374142777926451750173883915473608473490640555955254866539257198465042703245277077099845652190559018691106658572082103108758568513674878631668663108991293518722394008829295944165864669592209464562778983850320526716457297043651181142025876864450749761186342978473193634234771766626807908512474256920215018288365446686983828070743709887135352264921768262204958733788790387372545478963797565845429681695605312417553871988512463397438137432116077976056794304738307728658617430552348001341594296810880189730911110173774245470299924602947799793096435167707637099182091428394694026107937661524115659833870956152767282244963292912959485510336112736797599125367209553027347225737785920466421585722011564175502520711627869778597069792468006930131449566799893746060144447121224997671765365959836460300365493308438306487201777005959488854295401510240484843920186250269325762539806766006764887383527915386856995060586090468318097241078098844484584728453812502694785580967881787610330734967582316277139727157360783417820761568406817225428393415731833289889183164788380586858202748670865463785066279933704557522695476769630401248302564751900098348298937502466717879816094642141453730976993624373594660979787639431692134370049466255524734381965166051902928450330849458050550924785005517690122635341865356129893936390984312564095072641929896254366286955425483308937220013682667420119816099630410357756741685637204929036962639630284237780170170137048622458804740410316748405474193581287692336002784428040220665832447252014424521062403445276238645074122957030823389521190364226320576821793241466063653264546632446653710180657168855354589341995926811317954715317038104087200854402530701885984005159572731653530488688036384129238148449956938902826651143726793925539669634767285749371247366298546491817563525598691003331831118631532694111047824229437093657251238938656597448472410815039297040106787204783266375457985126036841411354901465439604147103743994860487186269436518126001993987901736526879258192793833949024063894147472461581729669617643736326326562581860192345474933286269462767111761606026776444181320919574650530696543016454625353722614896513964091947786094334954202757265532710157573697417607062598161458456225526852798448352197037902825186748089116883084782116845846245937576977919921790525474558308491045218021036345383194715979116462041794278608622393229614449795252765609534536322230468086817423838971959000051399728454574312278162814122968084669660744583410425116518085995508069481493962318750116473334973574465009548823250105043269539290762309127603349463159864152466342160915673325338661844496907516808930278548684944829747727293828022581991399046097152202932624820874876027293432060945733621327478854100717356409673612400408892613543468617155316073605776077042796194563027677217167071778606116190133131878939564594611927223542888111509701076902821164878797256711494945229393715838819088646942147128891553693225350011754291552259073858158571001708691663709783540719855233174559984156123098681921220018811896609523273789743139827508254370985579145799662143438190164729876315922892991414858225825449272000120452994487116286432782633700278570315290774031773393907116630477076363940931613061869165753194969173509247992896212321392791740844556840005894602006534187159513784894908731451675227901089550825258032470783557340126970690155988804414052135271870936647241253443817242031022742331017851656497943038048227967018906854696091959433066873041948225079080705408092702794476762705186681354948502674284274928034751466159560518615552753536083649117443629429915645968505718574036250429774943698826260557376539216219507010567354734173185021497114181540575337891132809816606798301426219985530727810605261501008678619218050593476570156815200382521766843064912208807697478431849156386716612300664608482736847576132543232827500914556980524847330470644926856813792181521636304075263292650665664573043004856336319104396081555980692051478905737260123016601948509199912845107141737699673591365016908314784955974213604569045171364169392298902091037359223154437751082276936092506445936688305950790062174684291302474645589447965777036548139747516520329128903628901421994840452830904122564360485264982966017749514763984166887895314113933500263775150382451849465755877661695354669209588390288608377913916878814894495284208373101894470859953003499673138476227549232754140918851936201913752137911372175954898857757359437044805197281848042605702895123530958087252541763264749192529199189097350468051690811672818056048687730358745539336503821767573084489602040226995061596351948288326619955652628797736673762831638311848362199698973162787997365258110766694399452010014413251608937430825661865803751480987687234911817305406403768804338507843647407330611273017033032699868103637471218814897368511179724744097863207146901741563674382884268771573685129363929842614549569210550850925934165607039111313682200777741634345992864145013575478320687759906653373039200443627066856685112268892159533763009792392379265227313880028066199092840760418604214899804368341750091719828748939780874728999715755707572779089838553218111277077374129519151137240286754334866979013877260125403610333353869292773847497450711552321888015089656667948230693674861402685124081300145102643146815377962211152076109655708621938724060212095088731538718336643874810606899178321207981078435555296407849519003660903483694287053511256931920790393132612367175074145653658716519484582926558685156177362196042901987994351251126041027240237499448947648954382590651244118036928011655903522625367960433749514156910039009029046086812596839232361284300031997618007523482042812917201566107104442483552146714878483815485680613941541903671214415810147781053429661354466288509446624002530645340983478946676257382276255193993034709398614031025047387345935209286812145165574286972945476251533285550608024685304820479781605569407946131532435524443130655340077182073494884664243638996538935171063203585992823223509788257166067741789099450149611617026147355004427811459013023292946684991021237949163572915886640553445795803155830402826821904400963143572277522193745357774139543890595449352989242466644302568937453134057087962197427257305842941584525434546589811370242843562804158664353384491241248546631833235062105319801896610018724186315509266888636073987714356196219173506192175467988413290307580123989052850014415172986702228921740641983307272068885908674256202844892457035718484021714091011491960761479799691904558535792531249893800811748758903744991916030069107505267604010662500335516414524835928890541084308212645237412711410370521353253616486395331446758276502394640680105885246200780193585064677195617903477253282257653497643578279602226639542937972486207741338232194778792439775129098134670015083759914165863414235767296556135782268763546321677240725279171286429896312387084282045833095606307565345851389988635844088118437810941620108157067918693387196887273209043914761459978740121933030253088301279077813071174350928989280316325170728804495264919223456131657371883402536403503916789429896529508122210970851233037663558133391424886574921717053704555760597853725603712421064017383817916655057348765377204228670191385093055769142014460158697194802881443439802829868401025298536858108055389540876347522761092929768254066087102908058329288934060916785747933541141444345354626698433510536617921397789075695490761062195440073428233508030812468083221984554904213600187442639727354182410992242090742908969457266362346702459114162945536885434995929933566567791712920935259934800134215054907440521025953974112439133709580493588163655276120619152125456163867588915934999749149444656062230483076819315546689695716420588320112987836539747557950383895351490476340993111964278203788227298265089537496687884602991532187145120239411407129884782936057341240152600504268289644357395494732320352882306757272298610190964722053741977057141247963779135696065500239305483113830430529967096230134532476058434404421962779210227620622765659838445372267499297678583081523108616010377098777626748559108385844699842429801590658351355671024596119597291784968891834651540237257378150625247861928809943710615466826987401521540639232652005700649424628061626016505073364989619298633159813689543303119786657751717459048613080907018653023557307975501934321166565473299317996130215375330333476635672208621390090714341676884460745587545591668167923083385226888943028722528877616756949652569694748382863260430300365423843847094087016097636660118530743920136437912552297202712507614649828261154830796542901325688015006201155644829613279697976846702738603010313546892035512707780170971806942946570517845354260716521794763496857168927851864910513301243144961666067281314474234545518688800780117853144267251515056191831219338011582903815598801491962509956747169085904611574372347155830338441107152537162368991325655362098877897187989680456030085131483398559658715273515308443969081231248391799788963105876608306375438228468614173610032295690677199455324524276886839031505970284650241691592889844376223708378296427523128094056780858090699106010621450319915182210013940437579471970328630596406887060399098915056394419158290023188491148532631491185806389089109538137642806908206786560035123016487534647444569977052199882957626527538181283747723085435103980326451613477681029176337894188709376546703247902096036499897586180778371417630147458224687681341792367723097498911570456887369776100935738422975708304553012775908272219497599661245240269722465833290567471548712538928405918220821736186634835353631258648611878998456282742661358710041847446791567019633900050125533413340457802704402061399741116743867675930012215766030726705632621269861544993747729882783552600075148616060742908270250859194607880611921831591296888780251930747669902403965644914092525395493729835397702887838613910554795742717474268079511902957360102647664420435430251290096234270284681864773230729240043240760989626852941991343992436696574947679372135570015714304474361099056121050209418524957556187824985955127169648855516314678607289300194961151031684850151621898445260284854498167890331728912914044692741835219307659966387094691750153103314193627170230497518125622371173466870350046320176120041267005435440439072739611080610981115122777484903166150778159996329354113429509311953591982072257987409090011174153474787164442950521863677457444948157476891454366459631798284291804204266846936298789592469400964045281250126115957545877198587235254816541721930188561048529223732284935083754063494786003354904052684851181734587751596136472473856659380935714303313798356910716471809813112426150796469834333044948468950142876672231757574128360155294617641425718237781723579470806236863101121193317174202017992257617429603364913808318227485191615630047765177809567967629123666571373089964783261824044295372206151940730709419839035582039666501039304885927017469020338767741943982482281696818842688266663433425904597248690921345161742545541347600162622169349302487683729095922296132570933456240568379377413637791693618669656170891682895585855637417623449609493138959901372395904117039035134675010216376668147082957478178893915371503089352201071249962942864570266829785805808381250450344187611442623042562685242883687599510466801394439644971991749344665198661187580745334231009449666676718402652088776977657422647966727655880867092846676941375394188835812783705685859642751909664344755976877790149856104059782398325560385612145766560140219984724603392393726246545271455425360509046757261610273196701489647338259419434569971068834526147156972773823567444657600370575863442670054779087211858773209502604688923034685783470083366688200078829382809642835057394206640101940057737224857030579564246949547799888559109758863590370785468152006591409126429301384806062247812007778061508983398774488550445940621716647224002156406555709026874256990964997743017909781750425367582506902124292117949299879719540172523372029706368471840636809640409057323476773826176628055646398761294072384132550936177750784450008343906738356611424917010038475720408425915450251361667639438118420114403691501007550875996380816215564348690707568249803706017734961778976767291486950160593880825345585598203704067747482583879700794030243318396300293211714283989289331999257344969440529507974121679766833104638093516135460963883206967340729635190495505908331330432262554039684651480140039866802516658637147119745248392389478176644799135506830562485429804183123108085514211456752087035711648715348240871773575796646283255054519786083211937793615300628947924500767659484340440638345682661592559368093 λ> lista [1,4,7,16] λ> :t lista lista :: [Integer] λ> :i lista lista :: [Integer] -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula9.hs:35:1 λ> :i fun fun :: Integer -> Integer -> Integer -> Integer -- Defined at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula9.hs:15:1 λ> :i zipWith zipWith :: (a -> b -> c) -> [a] -> [b] -> [c] -- Defined in `GHC.List' λ> :t map map :: (a -> b) -> [a] -> [b] λ> lista_de_fibos [1,3,13,987] λ> :t Maybe :1:1-5: error: * Illegal term-level use of the type constructor `Maybe' imported from `Prelude' at /home/hugo/Academic/Teaching/2023.2/TCPF/Aulas/Aula9.hs:1:8-12 (and originally defined in `GHC.Maybe') * In the expression: Maybe λ> :i Maybe type Maybe :: * -> * data Maybe a = Nothing | Just a -- Defined in `GHC.Maybe' instance Applicative Maybe -- Defined in `GHC.Base' instance Eq a => Eq (Maybe a) -- Defined in `GHC.Maybe' instance Functor Maybe -- Defined in `GHC.Base' instance Monad Maybe -- Defined in `GHC.Base' instance Semigroup a => Monoid (Maybe a) -- Defined in `GHC.Base' instance Ord a => Ord (Maybe a) -- Defined in `GHC.Maybe' instance Semigroup a => Semigroup (Maybe a) -- Defined in `GHC.Base' instance Show a => Show (Maybe a) -- Defined in `GHC.Show' instance MonadFail Maybe -- Defined in `Control.Monad.Fail' instance Read a => Read (Maybe a) -- Defined in `GHC.Read' instance Foldable Maybe -- Defined in `Data.Foldable' instance Traversable Maybe -- Defined in `Data.Traversable' λ> :i [] type [] :: * -> * data [] a = [] | a : [a] -- Defined in `GHC.Types' instance Applicative [] -- Defined in `GHC.Base' instance Eq a => Eq [a] -- Defined in `GHC.Classes' instance Functor [] -- Defined in `GHC.Base' instance Monad [] -- Defined in `GHC.Base' instance Monoid [a] -- Defined in `GHC.Base' instance Ord a => Ord [a] -- Defined in `GHC.Classes' instance Semigroup [a] -- Defined in `GHC.Base' instance Show a => Show [a] -- Defined in `GHC.Show' instance MonadFail [] -- Defined in `Control.Monad.Fail' instance Read a => Read [a] -- Defined in `GHC.Read' instance Foldable [] -- Defined in `Data.Foldable' instance Traversable [] -- Defined in `Data.Traversable' λ> :t (1 : 2) (1 : 2) :: (Num a, Num [a]) => [a] λ> :t (1 : 2 : []) (1 : 2 : []) :: Num a => [a] λ> :t [1,2] [1,2] :: Num a => [a] λ> [1,2] == 1 : 2 : [] True λ> :t (:) (:) :: a -> [a] -> [a] λ> :t (1:2) (1:2) :: (Num a, Num [a]) => [a] λ> :t (1 : 2) (1 : 2) :: (Num a, Num [a]) => [a] λ> 1:2 :93:1-3: error: * No instance for (Num [Integer]) arising from a use of `it' * In the first argument of `print', namely `it' In a stmt of an interactive GHCi command: print it λ> :t (:) (:) :: a -> [a] -> [a] λ> 1 : [2] [1,2] λ> :t (1,2) (1,2) :: (Num a, Num b) => (a, b) λ> :t (1:2) (1:2) :: (Num a, Num [a]) => [a] λ> 1 : [2,3] [1,2,3] λ> [] : [] [[]] λ> 1 : 2 : 3 : :100:13: error: parse error (possibly incorrect indentation or mismatched brackets) λ> 1 : 2 : 3 : [] [1,2,3] λ> :i [] type [] :: * -> * data [] a = [] | a : [a] -- Defined in `GHC.Types' instance Applicative [] -- Defined in `GHC.Base' instance Eq a => Eq [a] -- Defined in `GHC.Classes' instance Functor [] -- Defined in `GHC.Base' instance Monad [] -- Defined in `GHC.Base' instance Monoid [a] -- Defined in `GHC.Base' instance Ord a => Ord [a] -- Defined in `GHC.Classes' instance Semigroup [a] -- Defined in `GHC.Base' instance Show a => Show [a] -- Defined in `GHC.Show' instance MonadFail [] -- Defined in `Control.Monad.Fail' instance Read a => Read [a] -- Defined in `GHC.Read' instance Foldable [] -- Defined in `Data.Foldable' instance Traversable [] -- Defined in `Data.Traversable' λ> 1 : 2 :103:1-5: error: * No instance for (Num [Integer]) arising from a use of `it' * In the first argument of `print', namely `it' In a stmt of an interactive GHCi command: print it λ> :i Maybe type Maybe :: * -> * data Maybe a = Nothing | Just a -- Defined in `GHC.Maybe' instance Applicative Maybe -- Defined in `GHC.Base' instance Eq a => Eq (Maybe a) -- Defined in `GHC.Maybe' instance Functor Maybe -- Defined in `GHC.Base' instance Monad Maybe -- Defined in `GHC.Base' instance Semigroup a => Monoid (Maybe a) -- Defined in `GHC.Base' instance Ord a => Ord (Maybe a) -- Defined in `GHC.Maybe' instance Semigroup a => Semigroup (Maybe a) -- Defined in `GHC.Base' instance Show a => Show (Maybe a) -- Defined in `GHC.Show' instance MonadFail Maybe -- Defined in `Control.Monad.Fail' instance Read a => Read (Maybe a) -- Defined in `GHC.Read' instance Foldable Maybe -- Defined in `Data.Foldable' instance Traversable Maybe -- Defined in `Data.Traversable' λ> :t Nothing Nothing :: Maybe a λ> :i Functor type Functor :: (* -> *) -> Constraint class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a -> f b -> f a {-# MINIMAL fmap #-} -- Defined in `GHC.Base' instance Functor (Either a) -- Defined in `Data.Either' instance Functor [] -- Defined in `GHC.Base' instance Functor Solo -- Defined in `GHC.Base' instance Functor Maybe -- Defined in `GHC.Base' instance Functor IO -- Defined in `GHC.Base' instance Functor ((->) r) -- Defined in `GHC.Base' instance Functor ((,,,) a b c) -- Defined in `GHC.Base' instance Functor ((,,) a b) -- Defined in `GHC.Base' instance Functor ((,) a) -- Defined in `GHC.Base' λ> :i Monoid type Monoid :: * -> Constraint class Semigroup a => Monoid a where mempty :: a mappend :: a -> a -> a mconcat :: [a] -> a {-# MINIMAL mempty #-} -- Defined in `GHC.Base' instance Monoid [a] -- Defined in `GHC.Base' instance Monoid a => Monoid (Solo a) -- Defined in `GHC.Base' instance Monoid Ordering -- Defined in `GHC.Base' instance Semigroup a => Monoid (Maybe a) -- Defined in `GHC.Base' instance Monoid a => Monoid (IO a) -- Defined in `GHC.Base' instance Monoid b => Monoid (a -> b) -- Defined in `GHC.Base' instance (Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) -- Defined in `GHC.Base' instance (Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) -- Defined in `GHC.Base' instance (Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) -- Defined in `GHC.Base' instance (Monoid a, Monoid b) => Monoid (a, b) -- Defined in `GHC.Base' instance Monoid () -- Defined in `GHC.Base' λ> z [ 5, 6, 10 ] :108:1: error: Variable not in scope: z :: [a0] -> t λ> z [ 5, 6, 10 ] [5,8,55] λ>