welcome back I hope you've all installed GHz
and played a little bit by typing and expressions
over going to now is your moving beyond simple expressions
and see how we can law it full haskell programs
into GATT and and ask all programs are not called
programs typically as cool people refer to their code
scrimmage and because no I
is haskell programs are may be shorter than normal code
an I just call it has school programs
but yeah and the haskell parlance
is scripts again
so an new functions if you want to define a complete national program
you define them in a
text file that contains list function definitions
an and this text file
and the suffix dot HS and that indicates that that's
haskell file just like an hour an HTML file has an
dot HTML shop picture CSS files adult CS
CSS suffix or java file
and has a dot job on and some pics
haskell file is called whatever
dot HS again said not mandatory
but jus fault that you can see when you
list the files he a directory as you can see that this
has script now when you
are using am ght
what you do issue added your
script in one window using whatever editor of choice
and then whenever you make a change your note your
this script into and GATT and gonna start
executing expressions thats they're kinda workflow
that we will be using for Moshe the course over simple things
that's what you of course by your building commercial haskell applications
this is not what you do
you will compile them into standalone exe good balls
but for the purposes of this course this is the workflow okay so we have
the other end the open we have Ghei interpret their open
and then we will load the script saw in this case
we will create an a
text trial test don't HS and in there
reboot to function definitions the first one
at double-a actually goes exploits axe does what it promises
and that weekend great through ball by calling double of double effect
again so we save that file and then restart
Ghei and invoking its wet
dash dot HS and now boasts the Haskell standard library
and the functions a great dribble and double that we defined
in that test don't they just will be available so for example we gotta go
toward rubble of dan
at will return 14 but we got also
still call all this standard library functions for example
we can and take
double up to this list while FF do it for so this is a mistake for is that
correct
yes you read that the first for elements of the list
are you up and I what we do
is really just leave GHz open be returned to our editor
me at a
to new definitions Wallace pictorial
and the other one as average and says we're starting here
I have to be an hour we were using some syntax we haven't introduced yet show
bare wit me an so brother
of want to an this this thing here
you know it's the list of values Wong up to an
and then brother is the function standard library function
that multiplies all the values in a list so
this is a good definition affect RL and then when we want to calculate the
average
Ave lest what do we do read some
all the elements the value the elements and we divide that
by the length of the list of course this is not a very smart
implementation of average but that doesn't matter we're not
here to define average where we're doing this to learn
gati but the thing ever using here's this trick here in Haskell
is that when you put a function name
between these an single back quotes
and it becomes an infection operator
okay so if you ride X
back quotes at why
that's religious index you are for af
XY okay and some people like this thing as an infection operator
some people like it just as a regular operator
am it's your choice but this is syntactic convention show is another
string or anything
is really taking a function and turning that into an infection operator
then Ghei we call real out
an it will REITs did filed Estill
HS at all the new bindings that we just define show
that was for factorial so we can now call factorial
and then we can call average as well
so and here you see the workflow show you have your Gazi open your editor
you added Youghal reloads and then you can try
your code a fusion tactic
a thinks all the DC and Haskell functions
and parameter names must begin with lower case
letters okay saw
if you define a function and must be in our
of any of this form but the sea at any of these
starch with a lower case and
letter and you can use a regular quotes
a.m. if you're kind of too lazy to invent the name so that
something that I often mentioned other languages were just want to say
ex-prime
makes double prime et cetera okay
a.m. and if you define it type a dive has to start with an
a brick Asian and that's the kinda regions do in Haskell
the types and an identifiers
are different namespaces and that's determined
by where it starts with a lower case are
a brigade identifies it again be confusing if you come from a different
language like ask
like Java our C sharp or JavaScript am
then the other thing is that in the Haskell reuse she
gonna very mild form of Hungarian notation
so if a parameter hasn't
ass affects so for example if you have a parameter name
excess RN's or and is
that means a list of values
of dye packs and this is a list of values
up divan and sometimes the and doesn't correspond to the
typename but typically where you see an asset the and you know that it's a list
and if there's 2 S's at the end like here
you know that it's a list published an
and thats convention so if you want to look like a real hassle programmer
issued always use this convention parameters a list
is always and shred s and usually
haskell identifiers are short
saw you don't go let you know elements you call it excess
another
interesting thing that has school has in common with by Tom
is that white spaces significant and the
xx rules are quite so tall but
again we are just you know using has call
in very simple ways so dis
is gonna sufficient cell if you have a secretive definitions like here
they all have to start in the same column so here
a B&C all starts
in the same column an in this case here
air be as a space to the left of it
so now all these definitions don't start in the same column
that's wrong or in this case see
and a don't start in the same column SB
also wrong day
saw white space is significant in Haskell
to make sure that all your definitions are lined up this is called the layout
and the lead role again
is there to avoid riding
unnecessary syntax error at school folks
like to write this show a cosby plus she wear
and then in the WHERE clause he have Alicia definitions that
all start in the same column and then d
here stars in the same column at a
answered that belongs to the same group as a
and you can write this red explicit
curly braces in Senegal lunch if you want to
but thats and looks a lot more
for bush okay show has gold programmers like brevity
and so they'll see you significant white space
an and this looks a little bit like lani
and ask a world where you ride got like there's people got like
on then do an of wax on wax off
alright here some rget commands that are useful
an and I really
invite you to play around with it and when you do the exercises for
subsequent lectures make sure that your leverage
GHz or whatever other compiler use
to help you okay so we have seen and reload you can also just
LotusScript fresh crept you can
and from the a interpreter
opened the other terror so you can added
a file is your name or added the current script
and this wrong here shipper useful
if needed type of an expression and I do this
all the time never i touch myself I asked by the diapers and I go
in the editor and based in the type and
you definitely should use and go long question mark
and that gives you a list of all the commands am
wit a small explanation and of course
an I hope that you will not used had this
lost come out to Greg GHz an
but that you will got are for the next eight weeks
you will be constantly using GATT okay
showed there will be a lot of exercises and
the exercises will be on the website and
and all these exercises an
should be able to you should be able to do them and any language so you don't
have to use
GHz but in this case since this lecture is about
GHz and they will be
hehe specific all rights but in general
as I said in the very first lecture this is a course
about functional programming it's not a course about Haskell and it's definitely
not the course about GATT
but in this specific case exercises for destructor
for this lecture are on GTI
okay happy hacking and see you all next week