1 00:00:00,919 --> 00:00:05,140 welcome back I hope you've all installed GHz 2 00:00:05,140 --> 00:00:08,599 and played a little bit by typing and expressions 3 00:00:08,599 --> 00:00:13,330 over going to now is your moving beyond simple expressions 4 00:00:13,330 --> 00:00:18,350 and see how we can law it full haskell programs 5 00:00:18,350 --> 00:00:23,310 into GATT and and ask all programs are not called 6 00:00:23,310 --> 00:00:27,260 programs typically as cool people refer to their code 7 00:00:27,260 --> 00:00:30,689 scrimmage and because no I 8 00:00:30,689 --> 00:00:34,190 is haskell programs are may be shorter than normal code 9 00:00:34,190 --> 00:00:37,730 an I just call it has school programs 10 00:00:37,730 --> 00:00:41,550 but yeah and the haskell parlance 11 00:00:41,550 --> 00:00:44,899 is scripts again 12 00:00:44,899 --> 00:00:50,610 so an new functions if you want to define a complete national program 13 00:00:50,610 --> 00:00:53,870 you define them in a 14 00:00:53,870 --> 00:00:57,170 text file that contains list function definitions 15 00:00:57,170 --> 00:01:00,840 an and this text file 16 00:01:00,840 --> 00:01:06,040 and the suffix dot HS and that indicates that that's 17 00:01:06,040 --> 00:01:10,170 haskell file just like an hour an HTML file has an 18 00:01:10,170 --> 00:01:14,340 dot HTML shop picture CSS files adult CS 19 00:01:14,340 --> 00:01:17,890 CSS suffix or java file 20 00:01:17,890 --> 00:01:21,350 and has a dot job on and some pics 21 00:01:21,350 --> 00:01:25,000 haskell file is called whatever 22 00:01:25,000 --> 00:01:29,049 dot HS again said not mandatory 23 00:01:29,049 --> 00:01:32,320 but jus fault that you can see when you 24 00:01:32,320 --> 00:01:35,689 list the files he a directory as you can see that this 25 00:01:35,689 --> 00:01:40,210 has script now when you 26 00:01:40,210 --> 00:01:44,430 are using am ght 27 00:01:44,430 --> 00:01:47,530 what you do issue added your 28 00:01:47,530 --> 00:01:52,049 script in one window using whatever editor of choice 29 00:01:52,049 --> 00:01:55,259 and then whenever you make a change your note your 30 00:01:55,259 --> 00:01:59,460 this script into and GATT and gonna start 31 00:01:59,460 --> 00:02:03,590 executing expressions thats they're kinda workflow 32 00:02:03,590 --> 00:02:07,369 that we will be using for Moshe the course over simple things 33 00:02:07,369 --> 00:02:12,080 that's what you of course by your building commercial haskell applications 34 00:02:12,080 --> 00:02:13,420 this is not what you do 35 00:02:13,420 --> 00:02:16,450 you will compile them into standalone exe good balls 36 00:02:16,450 --> 00:02:21,550 but for the purposes of this course this is the workflow okay so we have 37 00:02:21,550 --> 00:02:25,950 the other end the open we have Ghei interpret their open 38 00:02:25,950 --> 00:02:30,150 and then we will load the script saw in this case 39 00:02:30,150 --> 00:02:33,880 we will create an a 40 00:02:33,880 --> 00:02:37,140 text trial test don't HS and in there 41 00:02:37,140 --> 00:02:40,840 reboot to function definitions the first one 42 00:02:40,840 --> 00:02:45,380 at double-a actually goes exploits axe does what it promises 43 00:02:45,380 --> 00:02:49,890 and that weekend great through ball by calling double of double effect 44 00:02:49,890 --> 00:02:55,459 again so we save that file and then restart 45 00:02:55,459 --> 00:02:59,690 Ghei and invoking its wet 46 00:02:59,690 --> 00:03:04,400 dash dot HS and now boasts the Haskell standard library 47 00:03:04,400 --> 00:03:08,220 and the functions a great dribble and double that we defined 48 00:03:08,220 --> 00:03:12,030 in that test don't they just will be available so for example we gotta go 49 00:03:12,030 --> 00:03:13,500 toward rubble of dan 50 00:03:13,500 --> 00:03:16,819 at will return 14 but we got also 51 00:03:16,819 --> 00:03:21,049 still call all this standard library functions for example 52 00:03:21,049 --> 00:03:24,660 we can and take 53 00:03:24,660 --> 00:03:30,070 double up to this list while FF do it for so this is a mistake for is that 54 00:03:30,070 --> 00:03:30,650 correct 55 00:03:30,650 --> 00:03:33,820 yes you read that the first for elements of the list 56 00:03:33,820 --> 00:03:39,200 are you up and I what we do 57 00:03:39,200 --> 00:03:44,540 is really just leave GHz open be returned to our editor 58 00:03:44,540 --> 00:03:47,579 me at a 59 00:03:47,579 --> 00:03:51,290 to new definitions Wallace pictorial 60 00:03:51,290 --> 00:03:56,750 and the other one as average and says we're starting here 61 00:03:56,750 --> 00:04:01,180 I have to be an hour we were using some syntax we haven't introduced yet show 62 00:04:01,180 --> 00:04:04,380 bare wit me an so brother 63 00:04:04,380 --> 00:04:08,100 of want to an this this thing here 64 00:04:08,100 --> 00:04:11,840 you know it's the list of values Wong up to an 65 00:04:11,840 --> 00:04:16,070 and then brother is the function standard library function 66 00:04:16,070 --> 00:04:19,169 that multiplies all the values in a list so 67 00:04:19,169 --> 00:04:24,330 this is a good definition affect RL and then when we want to calculate the 68 00:04:24,330 --> 00:04:25,480 average 69 00:04:25,480 --> 00:04:29,350 Ave lest what do we do read some 70 00:04:29,350 --> 00:04:33,780 all the elements the value the elements and we divide that 71 00:04:33,780 --> 00:04:38,020 by the length of the list of course this is not a very smart 72 00:04:38,020 --> 00:04:41,780 implementation of average but that doesn't matter we're not 73 00:04:41,780 --> 00:04:45,750 here to define average where we're doing this to learn 74 00:04:45,750 --> 00:04:51,220 gati but the thing ever using here's this trick here in Haskell 75 00:04:51,220 --> 00:04:55,280 is that when you put a function name 76 00:04:55,280 --> 00:04:59,390 between these an single back quotes 77 00:04:59,390 --> 00:05:02,580 and it becomes an infection operator 78 00:05:02,580 --> 00:05:06,290 okay so if you ride X 79 00:05:06,290 --> 00:05:09,620 back quotes at why 80 00:05:09,620 --> 00:05:12,900 that's religious index you are for af 81 00:05:12,900 --> 00:05:18,410 XY okay and some people like this thing as an infection operator 82 00:05:18,410 --> 00:05:21,640 some people like it just as a regular operator 83 00:05:21,640 --> 00:05:25,690 am it's your choice but this is syntactic convention show is another 84 00:05:25,690 --> 00:05:26,960 string or anything 85 00:05:26,960 --> 00:05:31,440 is really taking a function and turning that into an infection operator 86 00:05:31,440 --> 00:05:35,290 then Ghei we call real out 87 00:05:35,290 --> 00:05:39,020 an it will REITs did filed Estill 88 00:05:39,020 --> 00:05:42,920 HS at all the new bindings that we just define show 89 00:05:42,920 --> 00:05:46,410 that was for factorial so we can now call factorial 90 00:05:46,410 --> 00:05:49,610 and then we can call average as well 91 00:05:49,610 --> 00:05:54,520 so and here you see the workflow show you have your Gazi open your editor 92 00:05:54,520 --> 00:05:58,360 you added Youghal reloads and then you can try 93 00:05:58,360 --> 00:06:03,430 your code a fusion tactic 94 00:06:03,430 --> 00:06:07,960 a thinks all the DC and Haskell functions 95 00:06:07,960 --> 00:06:12,480 and parameter names must begin with lower case 96 00:06:12,480 --> 00:06:15,730 letters okay saw 97 00:06:15,730 --> 00:06:19,530 if you define a function and must be in our 98 00:06:19,530 --> 00:06:23,010 of any of this form but the sea at any of these 99 00:06:23,010 --> 00:06:26,720 starch with a lower case and 100 00:06:26,720 --> 00:06:30,580 letter and you can use a regular quotes 101 00:06:30,580 --> 00:06:34,310 a.m. if you're kind of too lazy to invent the name so that 102 00:06:34,310 --> 00:06:37,950 something that I often mentioned other languages were just want to say 103 00:06:37,950 --> 00:06:38,710 ex-prime 104 00:06:38,710 --> 00:06:42,520 makes double prime et cetera okay 105 00:06:42,520 --> 00:06:47,210 a.m. and if you define it type a dive has to start with an 106 00:06:47,210 --> 00:06:51,710 a brick Asian and that's the kinda regions do in Haskell 107 00:06:51,710 --> 00:06:55,130 the types and an identifiers 108 00:06:55,130 --> 00:06:58,180 are different namespaces and that's determined 109 00:06:58,180 --> 00:07:01,620 by where it starts with a lower case are 110 00:07:01,620 --> 00:07:05,540 a brigade identifies it again be confusing if you come from a different 111 00:07:05,540 --> 00:07:06,830 language like ask 112 00:07:06,830 --> 00:07:10,990 like Java our C sharp or JavaScript am 113 00:07:10,990 --> 00:07:15,000 then the other thing is that in the Haskell reuse she 114 00:07:15,000 --> 00:07:19,800 gonna very mild form of Hungarian notation 115 00:07:19,800 --> 00:07:22,930 so if a parameter hasn't 116 00:07:22,930 --> 00:07:27,700 ass affects so for example if you have a parameter name 117 00:07:27,700 --> 00:07:31,420 excess RN's or and is 118 00:07:31,420 --> 00:07:35,840 that means a list of values 119 00:07:35,840 --> 00:07:39,640 of dye packs and this is a list of values 120 00:07:39,640 --> 00:07:44,460 up divan and sometimes the and doesn't correspond to the 121 00:07:44,460 --> 00:07:49,360 typename but typically where you see an asset the and you know that it's a list 122 00:07:49,360 --> 00:07:52,460 and if there's 2 S's at the end like here 123 00:07:52,460 --> 00:07:55,910 you know that it's a list published an 124 00:07:55,910 --> 00:07:59,630 and thats convention so if you want to look like a real hassle programmer 125 00:07:59,630 --> 00:08:03,370 issued always use this convention parameters a list 126 00:08:03,370 --> 00:08:07,250 is always and shred s and usually 127 00:08:07,250 --> 00:08:10,410 haskell identifiers are short 128 00:08:10,410 --> 00:08:13,900 saw you don't go let you know elements you call it excess 129 00:08:13,900 --> 00:08:17,510 another 130 00:08:17,510 --> 00:08:21,370 interesting thing that has school has in common with by Tom 131 00:08:21,370 --> 00:08:25,050 is that white spaces significant and the 132 00:08:25,050 --> 00:08:28,100 xx rules are quite so tall but 133 00:08:28,100 --> 00:08:32,350 again we are just you know using has call 134 00:08:32,350 --> 00:08:35,630 in very simple ways so dis 135 00:08:35,630 --> 00:08:40,880 is gonna sufficient cell if you have a secretive definitions like here 136 00:08:40,880 --> 00:08:44,600 they all have to start in the same column so here 137 00:08:44,600 --> 00:08:47,760 a B&C all starts 138 00:08:47,760 --> 00:08:51,230 in the same column an in this case here 139 00:08:51,230 --> 00:08:55,300 air be as a space to the left of it 140 00:08:55,300 --> 00:08:58,780 so now all these definitions don't start in the same column 141 00:08:58,780 --> 00:09:01,860 that's wrong or in this case see 142 00:09:01,860 --> 00:09:04,990 and a don't start in the same column SB 143 00:09:04,990 --> 00:09:08,130 also wrong day 144 00:09:08,130 --> 00:09:11,460 saw white space is significant in Haskell 145 00:09:11,460 --> 00:09:15,600 to make sure that all your definitions are lined up this is called the layout 146 00:09:15,600 --> 00:09:19,290 and the lead role again 147 00:09:19,290 --> 00:09:22,660 is there to avoid riding 148 00:09:22,660 --> 00:09:26,080 unnecessary syntax error at school folks 149 00:09:26,080 --> 00:09:30,050 like to write this show a cosby plus she wear 150 00:09:30,050 --> 00:09:33,510 and then in the WHERE clause he have Alicia definitions that 151 00:09:33,510 --> 00:09:37,230 all start in the same column and then d 152 00:09:37,230 --> 00:09:40,440 here stars in the same column at a 153 00:09:40,440 --> 00:09:44,060 answered that belongs to the same group as a 154 00:09:44,060 --> 00:09:47,950 and you can write this red explicit 155 00:09:47,950 --> 00:09:51,920 curly braces in Senegal lunch if you want to 156 00:09:51,920 --> 00:09:55,700 but thats and looks a lot more 157 00:09:55,700 --> 00:09:59,850 for bush okay show has gold programmers like brevity 158 00:09:59,850 --> 00:10:03,110 and so they'll see you significant white space 159 00:10:03,110 --> 00:10:06,640 an and this looks a little bit like lani 160 00:10:06,640 --> 00:10:10,520 and ask a world where you ride got like there's people got like 161 00:10:10,520 --> 00:10:14,090 on then do an of wax on wax off 162 00:10:14,090 --> 00:10:21,090 alright here some rget commands that are useful 163 00:10:21,220 --> 00:10:24,330 an and I really 164 00:10:24,330 --> 00:10:29,620 invite you to play around with it and when you do the exercises for 165 00:10:29,620 --> 00:10:33,220 subsequent lectures make sure that your leverage 166 00:10:33,220 --> 00:10:36,800 GHz or whatever other compiler use 167 00:10:36,800 --> 00:10:41,930 to help you okay so we have seen and reload you can also just 168 00:10:41,930 --> 00:10:45,820 LotusScript fresh crept you can 169 00:10:45,820 --> 00:10:49,050 and from the a interpreter 170 00:10:49,050 --> 00:10:52,430 opened the other terror so you can added 171 00:10:52,430 --> 00:10:56,270 a file is your name or added the current script 172 00:10:56,270 --> 00:10:59,880 and this wrong here shipper useful 173 00:10:59,880 --> 00:11:03,550 if needed type of an expression and I do this 174 00:11:03,550 --> 00:11:08,330 all the time never i touch myself I asked by the diapers and I go 175 00:11:08,330 --> 00:11:11,589 in the editor and based in the type and 176 00:11:11,589 --> 00:11:15,959 you definitely should use and go long question mark 177 00:11:15,959 --> 00:11:19,649 and that gives you a list of all the commands am 178 00:11:19,649 --> 00:11:23,970 wit a small explanation and of course 179 00:11:23,970 --> 00:11:27,350 an I hope that you will not used had this 180 00:11:27,350 --> 00:11:31,079 lost come out to Greg GHz an 181 00:11:31,079 --> 00:11:34,450 but that you will got are for the next eight weeks 182 00:11:34,450 --> 00:11:39,709 you will be constantly using GATT okay 183 00:11:39,709 --> 00:11:43,010 showed there will be a lot of exercises and 184 00:11:43,010 --> 00:11:46,660 the exercises will be on the website and 185 00:11:46,660 --> 00:11:49,680 and all these exercises an 186 00:11:49,680 --> 00:11:54,510 should be able to you should be able to do them and any language so you don't 187 00:11:54,510 --> 00:11:55,600 have to use 188 00:11:55,600 --> 00:11:59,990 GHz but in this case since this lecture is about 189 00:11:59,990 --> 00:12:03,029 GHz and they will be 190 00:12:03,029 --> 00:12:06,610 hehe specific all rights but in general 191 00:12:06,610 --> 00:12:10,680 as I said in the very first lecture this is a course 192 00:12:10,680 --> 00:12:15,430 about functional programming it's not a course about Haskell and it's definitely 193 00:12:15,430 --> 00:12:17,320 not the course about GATT 194 00:12:17,320 --> 00:12:22,020 but in this specific case exercises for destructor 195 00:12:22,020 --> 00:12:25,250 for this lecture are on GTI 196 00:12:25,250 --> 00:12:29,459 okay happy hacking and see you all next week