
English: 
So, monads are a concept that was
invented in mathematics in the 1960s, and
then it was rediscovered in computer
science in the 1990s. And what it gives
you, is a new way of thinking about
programming with effects. And for me, this
is one of the most important new ideas
in programming languages in the last 25
years. So that's what we're going to be
looking at today - programming with monads.
We're going to come at this using a
simple example, and the example that
we're going to look at is the idea of
writing a function that evaluates simple
expressions. And I'm going to use Haskell
for this, but it doesn't matter if you don't
know anything about Haskell, because
we're going to use it in a very simple
way, and I'm going to explain everything
as we're going along. So, what we're going
to start with, is by defining a simple
datatype for the kind of expressions
that we're going to be evaluating. So,
we'll use the data keyword in Haskell,
which introduces a new data type, and
then we're going to define a new data

English: 
So, monads are a concept that was
invented in mathematics in the 1960s, and
then it was rediscovered in computer
science in the 1990s. And what it gives
you, is a new way of thinking about
programming with effects. And for me, this
is one of the most important new ideas
in programming languages in the last 25
years. So that's what we're going to be
looking at today - programming with monads.
We're going to come at this using a
simple example, and the example that
we're going to look at is the idea of
writing a function that evaluates simple
expressions. And I'm going to use Haskell
for this, but it doesn't matter if you don't
know anything about Haskell, because
we're going to use it in a very simple
way, and I'm going to explain everything
as we're going along. So, what we're going
to start with, is by defining a simple
datatype for the kind of expressions
that we're going to be evaluating. So,
we'll use the data keyword in Haskell,
which introduces a new data type, and
then we're going to define a new data

Turkish: 
Yani, monads olan bir kavram
1960'lı yıllarda matematikte icat edildi ve
sonra bilgisayarda yeniden keşfedildi
1990'larda bilim. Ve ne veriyor
sen, düşünmenin yeni bir yolu
efektlerle programlama. Ve benim için, bu
en önemli fikirlerden biri
Son 25 dilde programlama dilinde
yıl. Demek olacağımız şey bu
günümüze bakıyor - monadlarla programlama.
Bu şeye kullanarak geleceğiz.
basit örnek ve örnek
biz bakacağız fikri
basit değerlendiren bir fonksiyon yazma
ifade. Ve ben Haskell kullanacağım
bunun için, ama yapmaman önemli değil
Haskell hakkında bir şey biliyorsun, çünkü
çok basit bir şekilde kullanacağız
yol ve ben her şeyi açıklayacağım
devam ederken. Peki ne gidiyoruz
ile başlamak, basit bir tanımlayarak
ifadelerin türüne ilişkin veri türü
biz değerlendireceğiz. Yani,
Haskell’deki data anahtar sözcüğünü kullanacağız,
hangi yeni bir veri türü tanıtır ve
o zaman yeni bir veri tanımlayacağız

English: 
type for expressions. And then there's
two things that an expression can be. It
can either be an integer value, so we'll
write that down - we have Val of an Int.
Or, it can be the division of two
sub-expressions. So we've got two
constructors here in our
data type - we've got Val,
which builds expressions from integers, and
we've got Div, which builds expressions
from two sub-expressions. So, just to
reiterate what what's actually going on
here, we're declaring a new data type
called Expr, and it's got two new
constructors - one called Val, which
takes an integer parameter, and one
called Div, which takes two
sub-expressions as parameters as well.
So basically what we're working with is
expressions that are built up from
integer values using a simple division
operator. So, many of you may not be
familiar of this kind of syntax, so let's
have a couple of examples of values of
this data type, so that we make sure
everyone's on the same page. So, what I'm
going to do here, is draw a little table.
So, on one side, on the left-hand side, I'm

Turkish: 
ifadeler için tür. Ve sonra var
Bir ifadenin olabileceği iki şey. O
tamsayı bir değer olabilir, öyleyse
Bunu yaz - Val'in bir int.
Veya, iki bölümü olabilir
alt ifadeleri. Yani biz iki tane var
buradaki inşaatçılar
veri türü - elimizde Val,
tam sayılardan ifadeler oluşturan ve
İfadeleri oluşturan Div'e sahibiz
iki alt ifadeden. Yani, sadece
gerçekte neler olup bittiğini yineleyin
burada yeni bir veri türü ilan ediyoruz
Expr adında ve iki yeni
yapıcılar - Val denilen
bir tamsayı parametresi alır ve bir
Div adlı iki kişi
parametrelerin yanı sıra alt ifadeler.
Yani temelde çalıştığımız şey
yerleşik ifadeler
basit bir bölümü kullanarak tamsayı değerleri
Şebeke. Yani, çoğunuz olmayabilir
bu tür bir sözdizimine aşina olduğumuza göre
birkaç değer örneği var
bu veri türünden emin olmamız için
herkes aynı sayfada. Peki ben neyim
Burada yapacağım, küçük bir masa çizin.
Yani, bir tarafta, sol tarafta, ben

English: 
type for expressions. And then there's
two things that an expression can be. It
can either be an integer value, so we'll
write that down - we have Val of an Int.
Or, it can be the division of two
sub-expressions. So we've got two
constructors here in our
data type - we've got Val,
which builds expressions from integers, and
we've got Div, which builds expressions
from two sub-expressions. So, just to
reiterate what what's actually going on
here, we're declaring a new data type
called Expr, and it's got two new
constructors - one called Val, which
takes an integer parameter, and one
called Div, which takes two
sub-expressions as parameters as well.
So basically what we're working with is
expressions that are built up from
integer values using a simple division
operator. So, many of you may not be
familiar of this kind of syntax, so let's
have a couple of examples of values of
this data type, so that we make sure
everyone's on the same page. So, what I'm
going to do here, is draw a little table.
So, on one side, on the left-hand side, I'm

English: 
going to have what we would normally
write down in mathematics. And then on
the right-hand side, we'll think how
would you translate this into a value in
this Haskell data type? So, let's have
three simple examples here - we'll have
one, and we'll have
six divided by two, and
let's do one more example, we'll have six
divided by three divided by one. So, these are
simple expressions built up from integers
using a division operator. But, we're
writing Haskell programs today, so let's
think how do these things actually get
represented as values of our expression
data type? So, the first one is very
simple - if we want to represent the value
one, we just need to use the Val tag, so we
write Val of one. If we want to have an
expression like six divided by two, well it's
a division, so we have a Div at the top
level, and then we have two values - we
have Val six, and Val two. And actually, I'll
leave the last one is a little exercise
for you here, so you can try this one for
yourself - how do you represent this as a
value in Haskell? Well, you're gonna need
two divisions, you're going to need three

Turkish: 
normalde yapacağımız şeye sahip olacağız
matematiğe yazmak. Ve sonra
sağ tarafta nasıl düşüneceğimizi düşünelim
Bunu bir değere çevirir misiniz
Bu Haskell veri türü? Öyleyse alalım
Burada üç basit örnek - biz
bir, ve biz
altı bölü iki, ve
hadi bir örnek daha yapalım, altı
üçe bölünen bire bölünür. Demek bunlar
tamsayılardan oluşturulan basit ifadeler
bir bölme operatörü kullanarak. Ama biz
Bugün Haskell programlarını yazıyor, hadi
bu şeylerin gerçekte nasıl gerçekleştiğini düşünün
İfademizin değerleri olarak temsil edilir
veri tipi? Yani, birincisi çok
basit - eğer değeri temsil etmek istiyorsak
Birincisi, sadece Val etiketini kullanmamız gerekiyor.
Val in birini yaz. Eğer sahip olmak istiyorsak
altı gibi ifade ikiye bölünmüş, peki
bir bölünme, en üstte bir Div var
seviye ve sonra iki değerimiz var - biz
Val altı ve Val iki var. Ve aslında, ben
sonuncuyu bırak biraz egzersiz
burada senin için, böylece bunun için deneyebilirsin.
kendin - bunu nasıl temsil ediyorsun
Haskell değeri? Peki, ihtiyacın olacak
iki bölüm, üçe ihtiyacın olacak

English: 
going to have what we would normally
write down in mathematics. And then on
the right-hand side, we'll think how
would you translate this into a value in
this Haskell data type? So, let's have
three simple examples here - we'll have
one, and we'll have
six divided by two, and
let's do one more example, we'll have six
divided by three divided by one. So, these are
simple expressions built up from integers
using a division operator. But, we're
writing Haskell programs today, so let's
think how do these things actually get
represented as values of our expression
data type? So, the first one is very
simple - if we want to represent the value
one, we just need to use the Val tag, so we
write Val of one. If we want to have an
expression like six divided by two, well it's
a division, so we have a Div at the top
level, and then we have two values - we
have Val six, and Val two. And actually, I'll
leave the last one is a little exercise
for you here, so you can try this one for
yourself - how do you represent this as a
value in Haskell? Well, you're gonna need
two divisions, you're going to need three

Turkish: 
Val kurucuları ve sonra bir demet
parantez. Yani, bu temel fikir -
basit ifadeler oluşturduk
bölmeyi kullanan tamsayılardan
program yazmayı düşünmek
Bu ifadeleri değerlendirmek için? Haydi
Bunu yapmak için bir program yazın. Yani biz
bir değerlendirici yazacak ve
bir program veya bir işlev olacak
Bu durumda, bu bir ifadeyi alır.
girdi ve geri vereceği şey
bu ifadenin tamsayı değeridir.
Ve burada iki dava olacak.
çünkü iki tür ifademiz var.
Değerler için bir vakamız var ve buna ihtiyacımız var.
Bununla ne yapacağını çöz.
birazdan yapacağız. Ve sonra biz bir
bölünme davası ve düşünmemiz gerek
bununla ne yapmalı. Yani, biz var
Burada bir programın iskeleti ve sonra biz
sadece detayları doldurmanız gerekiyor. Nasıl
bir tamsayı değeri değerlendirir misiniz? İyi,
bu çok basit, sadece geri verirsin
sayı - öyleyse bir Val'im olsaydı,
bu değer sadece bir tanesidir. Ve sonra ben nasıl yaparım
bölümü değerlendirmek? Peki, bu ikisi

English: 
Val constructors, and then a bunch of
brackets. So, this is the basic idea - 
we've got simple expressions built up
from integers using division, and we want
to think about how do we write a program
to evaluate these expressions? Let's
write a program to do that. So, we're
going to write an evaluator, and it's
going to be a program, or a function in
this case, that takes an expression as
input, and what it's going to give back
is the integer value of that expression.
And there's going to be two cases here,
because we have two kinds of expressions.
We have a case for values, and we need to
figure out what to do with that, which
we'll do in a moment. And then we have a
case for division, and we need to think
what to do with that. So, we've got the
skeleton here of a program, and then we
just need to fill in the details. So, how
do you evaluate an integer value? Well,
that's very simple, you just give back
the number - so if I had Val of one,
it's value is just one. And then how do I
evaluate a division? Well, these two

English: 
Val constructors, and then a bunch of
brackets. So, this is the basic idea - 
we've got simple expressions built up
from integers using division, and we want
to think about how do we write a program
to evaluate these expressions? Let's
write a program to do that. So, we're
going to write an evaluator, and it's
going to be a program, or a function in
this case, that takes an expression as
input, and what it's going to give back
is the integer value of that expression.
And there's going to be two cases here,
because we have two kinds of expressions.
We have a case for values, and we need to
figure out what to do with that, which
we'll do in a moment. And then we have a
case for division, and we need to think
what to do with that. So, we've got the
skeleton here of a program, and then we
just need to fill in the details. So, how
do you evaluate an integer value? Well,
that's very simple, you just give back
the number - so if I had Val of one,
it's value is just one. And then how do I
evaluate a division? Well, these two

Turkish: 
Burada ifadeler, x ve y, bunlar olabilir
istediğiniz kadar karmaşık. Yani, ihtiyacımız var
bunları özyinelemeli olarak değerlendirin. Peki biz neyiz
yapar, ilkini değerlendirir, x ve
Bu bize bir tamsayı verecek. Ve sonra
ikincisini değerlendireceğiz, y ve
bize başka bir tamsayı verecek. Ve sonra,
tek yapmamız gereken tek tek bölmek
diğer. Yani, bu güzel, basit bir program
bu tür ifadeleri değerlendiren
bölünmeyi kullanan tamsayılardan - biz
sadece basit bir özyinelemeli program var, iki
davalar ve her şey görünüyor
ince. Ama var
ve bu programla ilgili sorun
sorun çökmesine neden olabilir - çünkü eğer
bir sayıyı sıfıra bölersen o zaman
tanımsız, bu yüzden bu program sadece
kazasında. Yani, özellikle, eğer değeri
Buradaki y ifadesi sıfırdı, sonra bu
bölüm operatörü çökecek ve sen
bir tür çalışma zamanı hatası alıyorum. Yani biz
programlarımızın çökmesini istemiyoruz, öyleyse biz
düşünüyorum, bu sorunu çözmek için ne yapacağız?
Her şeyden önce, yapacağımız şey
güvenli bir versiyonunu tanımlayacağız
olmayan bölme operatörü
artık çarpmak. Çünkü bu temelde

English: 
expressions here, x and y, these could be
as complicated as you wish. So, we need to
evaluate these recursively. So what we
would do, is evaluate the first one, x, and
that will give us an integer. And then
we'll evaluate the second one, y, and that
will give us another integer. And then,
all we need to do is divide one by the
other. So, this is a nice simple program
that evaluates these kind of expressions
built up from integers using division - we
just have a simple recursive program, two
cases, and everything looks
fine. But there's a
problem with this program, and the
problem is that it may crash - because if
you divide a number by zero, then that's
undefined, so this program will just
crash. So, in particular, if the value of
the expression y here was zero, then this
division operator would crash, and you
get some kind of runtime error. So we
don't want our programs to crash, so we
think, what do we do to fix this problem?
First of all, what we're going to do is
we're going to define a safe version of
the division operator, which doesn't
crash anymore. Because that's basically

English: 
expressions here, x and y, these could be
as complicated as you wish. So, we need to
evaluate these recursively. So what we
would do, is evaluate the first one, x, and
that will give us an integer. And then
we'll evaluate the second one, y, and that
will give us another integer. And then,
all we need to do is divide one by the
other. So, this is a nice simple program
that evaluates these kind of expressions
built up from integers using division - we
just have a simple recursive program, two
cases, and everything looks
fine. But there's a
problem with this program, and the
problem is that it may crash - because if
you divide a number by zero, then that's
undefined, so this program will just
crash. So, in particular, if the value of
the expression y here was zero, then this
division operator would crash, and you
get some kind of runtime error. So we
don't want our programs to crash, so we
think, what do we do to fix this problem?
First of all, what we're going to do is
we're going to define a safe version of
the division operator, which doesn't
crash anymore. Because that's basically

English: 
the root of the problem here - division by
zero gives an undefined result, and the
program is going to crash. So, let's
define a safe version of the division
operator. We're going to define a
function called safediv, and it's going
to take a couple of integers, and it's
going to give back Maybe an integer. And
Maybe is the way that we deal with
things that can possibly fail in Haskell.
So, the type here is not Int to Int to Int,
it's Int to Int to Maybe Int, because
division may fail. And we'll see how this
Maybe type works in a moment. So, how do
we actually define safediv? We take two
integers, n and m, and then what we'll do
is check - is the second of these zero?
Because that's the case when things
would go wrong. So, if m happened to be
zero, then we will give back the result
Nothing. Okay, so Nothing is one of the
constructors in the Maybe type. If m is
not zero, what we're going to do is Just
give back the result of dividing. So, Just
is another constructor in the Maybe type -
Maybe only has two constructors, Nothing,

English: 
the root of the problem here - division by
zero gives an undefined result, and the
program is going to crash. So, let's
define a safe version of the division
operator. We're going to define a
function called safediv, and it's going
to take a couple of integers, and it's
going to give back Maybe an integer. And
Maybe is the way that we deal with
things that can possibly fail in Haskell.
So, the type here is not Int to Int to Int,
it's Int to Int to Maybe Int, because
division may fail. And we'll see how this
Maybe type works in a moment. So, how do
we actually define safediv? We take two
integers, n and m, and then what we'll do
is check - is the second of these zero?
Because that's the case when things
would go wrong. So, if m happened to be
zero, then we will give back the result
Nothing. Okay, so Nothing is one of the
constructors in the Maybe type. If m is
not zero, what we're going to do is Just
give back the result of dividing. So, Just
is another constructor in the Maybe type -
Maybe only has two constructors, Nothing,

Turkish: 
burada sorunun kökü - bölü
sıfır tanımsız bir sonuç verir ve
program çökecek. Öyleyse, hadi
bölümün güvenli bir sürümünü tanımlayın
Şebeke. Tanımlayacağız
safediv adı verilen işlev
birkaç tamsayı almak için
geri vereceğim Belki bir tamsayı. Ve
Belki de başa çıkmamızın yolu budur.
Haskell'de muhtemelen başarısız olabilecek şeyler.
Yani, buradaki tür Int'den Int'ye değil,
belki int için int, çünkü int
bölünme başarısız olabilir. Ve bunu nasıl göreceğiz
Belki yazı birazdan çalışır. Peki nasıl
aslında safediv'i tanımlıyoruz? İki tane alırız
tamsayılar, n ve m ve sonra ne yapacağız?
kontrol - Bu sıfırı ikinci mi?
Çünkü işler böyle olduğunda
yanlış giderdi. Öyleyse, eğer m olsaydı
sıfır, sonra sonucu geri vereceğiz
Hiçbir şey değil. Tamam, yani hiçbir şey
Belki türünde yapıcılar. M ise
sıfır değil, yapacağımız şey sadece
bölmenin sonucunu geri vermek. Bu yüzden sadece
Belki türünde başka bir kurucu -
Belki sadece iki kurucu vardır, Hiçbir şey,

English: 
which represents things that have gone
wrong, or in our case division by zero,
and Just, which represent things that
have gone fine. In this case, we actually
just get back the result of dividing one
number by the other. So, what we have here
now is a safe version of the division
operator, which is explicitly checking
for the case when the program would have
crashed. So this doesn't crash anymore, it
returns one of two values - either Nothing
if things go wrong, or Just of the
division if things have gone fine. So,
what we can do then, with this safe
division operator, is rewrite our little
evaluator program to make sure that it
doesn't crash. So, our new evaluator is
going to have a slightly different type
than before. So before, the original
program just took an expression
as input, and then it gave back an
integer. But that program could crash. The
new evaluator takes an expression as
input as before, but now it Maybe gives
you an integer, because it could fail, it
could have division by zero. So, how do we
rewrite this evaluator? So, we'll do the
two cases again - write down the skeleton,

Turkish: 
olan şeyleri temsil eden
yanlış veya bizim durumumuzda sıfıra bölünme,
ve sadece, bu şeyleri temsil eden
iyi gitti. Bu durumda, biz aslında
Sadece bir bölen sonucu geri almak
diğer numara. Peki, burada ne var
şimdi bölümün güvenli bir versiyonu
açıkça denetleyen operatör
programın ne zaman olacağı
çöktü. Yani bu artık çökmeyecek
iki değerden birini döndürür
Eğer işler ters giderse, ya da Sadece
işler yolunda giderse bölünme. Yani,
o zaman ne yapabiliriz, bu kasayla
bölüm operatörü, bizim küçük yeniden yazmak
Değerlendirici programdan emin olmak için
çökmez Yani, yeni değerlendiricimiz
biraz farklı bir tür olacak
öncekinden daha. Bundan önce, orijinal
program daha yeni ifade aldı
girdi olarak, ve sonra geri
tamsayı. Ancak bu program çökebilir.
Yeni değerlendirici, ifadesini alır.
daha önce olduğu gibi girdi, ama şimdi belki verir
sen bir tamsayı, çünkü başarısız olabilir,
sıfır ile bölme olabilir. Peki nasıl?
bu değerlendiriciyi yeniden yazmak? Yani biz yapacağız
yine iki dava - iskeleti bir yere yaz,

English: 
which represents things that have gone
wrong, or in our case division by zero,
and Just, which represent things that
have gone fine. In this case, we actually
just get back the result of dividing one
number by the other. So, what we have here
now is a safe version of the division
operator, which is explicitly checking
for the case when the program would have
crashed. So this doesn't crash anymore, it
returns one of two values - either Nothing
if things go wrong, or Just of the
division if things have gone fine. So,
what we can do then, with this safe
division operator, is rewrite our little
evaluator program to make sure that it
doesn't crash. So, our new evaluator is
going to have a slightly different type
than before. So before, the original
program just took an expression
as input, and then it gave back an
integer. But that program could crash. The
new evaluator takes an expression as
input as before, but now it Maybe gives
you an integer, because it could fail, it
could have division by zero. So, how do we
rewrite this evaluator? So, we'll do the
two cases again - write down the skeleton,

English: 
and then we'll fill in the details. So, in
the base case, we can't just return n
this time, because we've got to return a
Maybe value. And there's only two things
we could return, either Nothing or Just,
and in this case the right thing to do
is to return Just of n, because if you
evaluate a value that's always going to
succeed, so we use a success tag, which
is Just, and then we have the integer
value sitting in here. If we have a
division, now we need to do a bit more
work, because when we evaluate x that may
fail, when we evaluate y that may fail,
and then when we do the division that
may fail. So, we're going to need to do a
little bit of checking and management of
failure. So, what we're going to do, is
when we evaluate a division, first of all,
we'll do a case analysis on the result
of evaluating x. And that could be one of
two things - it could either be Nothing, in
which case we're going to do something,
or we could get Just of some number, in
which case we're going to do something.  So,
there's two cases to consider - when we
evaluate the first parameter x, either it
succeeds or it fails. So in the failure

English: 
and then we'll fill in the details. So, in
the base case, we can't just return n
this time, because we've got to return a
Maybe value. And there's only two things
we could return, either Nothing or Just,
and in this case the right thing to do
is to return Just of n, because if you
evaluate a value that's always going to
succeed, so we use a success tag, which
is Just, and then we have the integer
value sitting in here. If we have a
division, now we need to do a bit more
work, because when we evaluate x that may
fail, when we evaluate y that may fail,
and then when we do the division that
may fail. So, we're going to need to do a
little bit of checking and management of
failure. So, what we're going to do, is
when we evaluate a division, first of all,
we'll do a case analysis on the result
of evaluating x. And that could be one of
two things - it could either be Nothing, in
which case we're going to do something,
or we could get Just of some number, in
which case we're going to do something.  So,
there's two cases to consider - when we
evaluate the first parameter x, either it
succeeds or it fails. So in the failure

Turkish: 
ve sonra detayları doldururuz. Yani, içinde
temel dava, sadece n geri dönemeyiz
bu sefer, çünkü geri dönmek zorundayız.
Belki değer. Ve sadece iki şey var
geri dönebiliriz, ya hiçbir şey ya da sadece
ve bu durumda yapılacak doğru şey
Sadece n geri dönmek içindir, çünkü eğer
her zaman olacak bir değeri değerlendirmek
başarılı olun, bu nedenle bir başarı etiketi kullanıyoruz.
Sadece, ve sonra tamsayıya sahibiz
Burada oturan değer. Eğer bir
bölünme, şimdi biraz daha yapmamız gerekiyor
çalışmak, çünkü x'i değerlendirdiğimizde
başarısız, y'yi değerlendirdiğimizde başarısız olabilir,
ve sonra bölünme yaptığımızda
Başarısız olabilir. Yani yapmamız gerekecek
kontrol ve yönetim biraz
hatası. Yani, yapacağımız şey,
Bir bölümü değerlendirdiğimizde, her şeyden önce,
sonuç üzerinde bir vaka analizi yapacağız
Değerlendirmenin x. Ve bu biri olabilir
iki şey - bu hiçbiri olabilir, içinde
hangi durumda bir şey yapacağız
ya da sadece bir sayı alabiliriz,
hangi durumda bir şey yapacağız. Yani,
dikkate alınması gereken iki durum var - biz
ilk parametreyi x değerlendirebilir
başarılı veya başarısız. Yani başarısızlıkta

English: 
case, if we get back Nothing, the only
sensible thing to do is just to say, well
if evaluation of x fails, the evaluation
of the whole division fails. So we'll
just return Nothing as well. In the Just
case, then we need to evaluate the second
parameter y. So, what we're going to do is
do another case analysis, we'll do a case
eval of y, and then again there's two
possible outcomes which we could have
here - either we could have Nothing, which
means it failed, or we could have Just of m,
some other number, in which case we've
succeeded. Then again, we need to think
what do we do in each of these two cases.
So, in the first case, if the evaluation
of y fails, the only sensible thing to do
is say, well, we fail as well. In the
second case, we've now got to
successfully evaluated expressions - x has
given the result n, y has given the
result m, and now we can do the safe
division. So, in this case we just do
safediv.  Now we have a working evaluator.
We started off with a two-line program,
which kind of did the essence of
evaluation, but it didn't check for
things going wrong - it didn't check for a

Turkish: 
davayı geri alırsak, hiçbir şey, sadece
Yapılması gereken mantıklı bir şey sadece demek ki
x değerlendirmesi başarısız olursa, değerlendirme
Tüm bölüm başarısız. Çok iyi
Sadece hiçbir şey de döndürmeyin. Sadece
durumda, sonra ikinci değerlendirmemiz gerekiyor
parametre y. Peki, yapacağımız şey
başka bir vaka analizi yap, bir dava yapalım
y 'nin değerlendirmesi ve sonra yine iki tane var.
sahip olabileceğimiz olası sonuçlar
burada - ya biz hiçbir şeyimiz olabilirdi ki
başarısız olduğu anlamına gelir, yoksa sadece m olabilir.
başka bir numara, bu durumda biz
başarılı oldu. Sonra tekrar düşünmemiz gerek
Bu iki olayın her birinde ne yapıyoruz?
Yani, ilk durumda, eğer değerlendirme
Y başarısız, yapılacak tek mantıklı şey
demek ki, biz de başarısızız. İçinde
ikinci dava, şimdi yapmalıyız.
başarıyla değerlendirilen ifadeler - x
n sonucu verilmişse, y
sonuç m, ve şimdi güvenli yapabiliriz
bölünme. Yani, bu durumda biz sadece
safediv. Şimdi çalışan bir değerlendiricimiz var.
İki satırlık bir programla başladık,
hangi tür özü yaptı
değerlendirme, ancak kontrol etmedi
yanlış giden şeyler var;

English: 
case, if we get back Nothing, the only
sensible thing to do is just to say, well
if evaluation of x fails, the evaluation
of the whole division fails. So we'll
just return Nothing as well. In the Just
case, then we need to evaluate the second
parameter y. So, what we're going to do is
do another case analysis, we'll do a case
eval of y, and then again there's two
possible outcomes which we could have
here - either we could have Nothing, which
means it failed, or we could have Just of m,
some other number, in which case we've
succeeded. Then again, we need to think
what do we do in each of these two cases.
So, in the first case, if the evaluation
of y fails, the only sensible thing to do
is say, well, we fail as well. In the
second case, we've now got to
successfully evaluated expressions - x has
given the result n, y has given the
result m, and now we can do the safe
division. So, in this case we just do
safediv.  Now we have a working evaluator.
We started off with a two-line program,
which kind of did the essence of
evaluation, but it didn't check for
things going wrong - it didn't check for a

English: 
division by zero.  Now we've
fixed the problem completely, we
have a program which works, this program
will never crash, it will always give a
well-defined result, either Nothing or
Just, but there's a bit of a problem with
this program, in that it's a bit too
long. It's a bit too verbose, there's
quite a lot of noise in here, I can
hardly see what's going on anymore,
because it's all of this management of
failure. So, we can look at this program,
and think - how can we make this program
better? And how can we make it more like
the original program, that didn't work,
but still maintain the fact that this
actually does the right thing? And the
idea here, is we're going to observe a
common pattern. So, when you look at this
program, you can see quite clearly we're
doing the same thing twice - we're doing
two case analyses. What we're doing, is
doing a case analysis on the result of
evaluating x, and if it's Nothing we give
back Nothing, and if it's Just, we do
something with the result. And then we do
exactly the same thing with eval of y -
we're doing a case analysis on the
result of evaluating y, if that gives
Nothing we give back Nothing, and if it's

English: 
division by zero.  Now we've
fixed the problem completely, we
have a program which works, this program
will never crash, it will always give a
well-defined result, either Nothing or
Just, but there's a bit of a problem with
this program, in that it's a bit too
long. It's a bit too verbose, there's
quite a lot of noise in here, I can
hardly see what's going on anymore,
because it's all of this management of
failure. So, we can look at this program,
and think - how can we make this program
better? And how can we make it more like
the original program, that didn't work,
but still maintain the fact that this
actually does the right thing? And the
idea here, is we're going to observe a
common pattern. So, when you look at this
program, you can see quite clearly we're
doing the same thing twice - we're doing
two case analyses. What we're doing, is
doing a case analysis on the result of
evaluating x, and if it's Nothing we give
back Nothing, and if it's Just, we do
something with the result. And then we do
exactly the same thing with eval of y -
we're doing a case analysis on the
result of evaluating y, if that gives
Nothing we give back Nothing, and if it's

Turkish: 
sıfıra bölüm. Şimdi biz var
sorunu tamamen düzelttik,
çalışan bir program var, bu program
asla çökmeyecek, daima
iyi tanımlanmış sonuç, Hiçbir şey veya
Sadece, ama biraz problem var
Bu program, bu da biraz
uzun. Biraz fazla ayrıntılı, var
Burada oldukça fazla gürültü var.
artık ne olup bittiğini görmek zor
çünkü bütün bu yönetim
hatası. Yani, bu programa bakabiliriz,
ve düşünün - bu programı nasıl yapabiliriz
daha iyi? Ve nasıl daha fazla hale getirebiliriz
Orijinal program işe yaramadı.
ama yine de bu gerçeği korumak
aslında doğru olanı yapar mı? Ve
Burada fikir, biz bir gözlemlemek için gidiyoruz
ortak kalıp Yani, buna baktığında
programı oldukça açık bir şekilde görebilirsiniz.
aynı şeyi iki kez yapıyorum - yapıyoruz
iki vaka analizi. Yaptığımız şey
sonucu üzerinde bir vaka analizi yapmak
x'in değerlendirilmesi ve verdiğimiz bir şey değilse
geri Hiçbir şey, ve eğer Sadece, yaparız
sonucu olan bir şey. Ve sonra yaparız
y'nin değerlendirmesi ile tamamen aynı şey -
hakkında bir vaka analizi yapıyoruz
y değerlendirmesinin sonucu, eğer
Hiçbir şey geri vermeyiz Hiçbir şey, eğer öyleyse

English: 
a Just, we do something with it.  So,
a very common idea in computing is
when you see the same things multiple
times, you abstract them out, and have
them as a definition. And that's what
we're going to do here. So, let's draw a
little picture first, to capture the
pattern which we've seen twice. So, the
pattern we have here, is we're doing a
case analysis on something, so let me
just draw as a little box - we don't know
what's in there, we're doing a case
analysis on something. And, there's two
cases - if it's Nothing, we give back
Nothing, and if we get Just of some value x,
then what we're going to do is we're
going to process it in some way, we're
going to apply some other function to x.
So, this is the pattern which we've seen
twice. In the first case, we had eval of x
sitting here, and in the second case, we
had eval of y sitting here, but this is
the same pattern that we see two
times in the new evaluator
which we've just written. So, what we
can do now, is abstract this out as a
definition. And the idea here, is that
we're going to give names to these boxes.

English: 
a Just, we do something with it.  So,
a very common idea in computing is
when you see the same things multiple
times, you abstract them out, and have
them as a definition. And that's what
we're going to do here. So, let's draw a
little picture first, to capture the
pattern which we've seen twice. So, the
pattern we have here, is we're doing a
case analysis on something, so let me
just draw as a little box - we don't know
what's in there, we're doing a case
analysis on something. And, there's two
cases - if it's Nothing, we give back
Nothing, and if we get Just of some value x,
then what we're going to do is we're
going to process it in some way, we're
going to apply some other function to x.
So, this is the pattern which we've seen
twice. In the first case, we had eval of x
sitting here, and in the second case, we
had eval of y sitting here, but this is
the same pattern that we see two
times in the new evaluator
which we've just written. So, what we
can do now, is abstract this out as a
definition. And the idea here, is that
we're going to give names to these boxes.

Turkish: 
Sadece bir şey yapalım. Yani,
hesaplamada çok yaygın bir fikir
aynı şeyleri birden çok gördüğünüzde
onları soyutlarsın ve
onları bir tanım olarak. Ve bu ne
burada yapacağız. Yani, bir çizelim
ilk küçük resim, yakalamak için
iki kere gördüğümüz desen. Böylece
Burada sahip olduğumuz desen, yapıyoruz
bir şey üzerinde vaka analizi, o yüzden bırakayım
sadece küçük bir kutu çizin - bilmiyoruz
içeride ne var, dava açıyoruz
bir şeyin analizi. Ve iki tane var
servis talebi - Eğer bir şey değilse geri veriyoruz
Hiçbir şey, ve eğer sadece x değerinden alırsak,
o zaman yapacağımız şey biziz
bir şekilde işleyeceğiz, biz
başka bir işlevi x'e uygulayacağım.
Demek gördüğümüz kalıp bu
iki defa. İlk durumda, x'in değerlendirmesini yaptık.
burada oturuyor ve ikinci durumda, biz
Burada oturup y değerlendirmek vardı, ama bu
iki gördüğümüz aynı
Yeni Değerlendiricideki Kez
ki biz sadece yazdık. Peki biz neyiz
şimdi yapabilir, bunu bir
tanım. Ve buradaki fikir şudur:
bu kutulara isimler vereceğiz.

Turkish: 
Yani, bu kutu Belki bir değerdir - gidiyor
ya bir hiç ya da adil olmak, öyleyse biz
ona m de Ve bu kutu gidiyor
bir işlev olmak için gidiyor
sonucu işleme koyarız
başarılı, bu yüzden buna f diyeceğiz. Yani biz
bu resmi buraya dönüştürebilir
Şimdi tanımı ve sonra bunu kullanabiliriz.
programımızı kolaylaştırın. Böylece
tanımı biz,
Belki bir değerimiz varsa, besleniriz,
veya bazı işlevlerle f sırasıyla. Yani,
burada tanımladığımız operatör
Bu komik sıralama sembolü ve biz
bir saniyede buna geri dönelim. Biz neyiz
yapacağım, bir vaka analizi - biz
Belki neye bakacağım
değer - eğer bir şey değilse,
biz hiçbir şey vermeyeceğiz, ve eğer sadece
x işlevini uygulayacağız. Tamam,
bu yüzden sadece deseni yakalayacağız.
Şimdi bir tanım gereği iki kere gördük. Yani,
O zaman veya içinde Belki değerimiz var
bazı işlevler f ve diğerleri
ne yapacağız bakalım ne olacak
Belki değeri - eğer başarısız olursa,
Başarısız olacağız, eğer başarılı olursa,
f fonksiyonunun sonucu. Sadece

English: 
So, this box is a Maybe value - it's going
to be either Nothing or a Just, so we'll
call it m. And this box is going
to be a function, it's going
process the result in the case we're
successful, so we'll call this f. So, we
can turn this picture here into a
definition now, and then we can use it to
make our program simpler.  So, the
definition we're going to have is,
if we have some Maybe value, feeding into,
or in sequence with, some function f. So,
the operator we're defining here is
this funny sequencing symbol, and we'll
back to that in a second. What we're
going to do, is a case analysis - we're
going to look at what the Maybe
value is - if it's Nothing,
we'll give back Nothing, and if it's Just
of x, we'll apply the function to it. Okay,
so we'll just captured the pattern, which
we've seen twice, by a definition now. So,
we have some Maybe value, then, or in
sequence with, some function f, and all
we're going to do is look at what the
value of the Maybe is - if it's failed,
we'll fail, if it succeeds, we pass the
result to the function f. It's just the

English: 
So, this box is a Maybe value - it's going
to be either Nothing or a Just, so we'll
call it m. And this box is going
to be a function, it's going
process the result in the case we're
successful, so we'll call this f. So, we
can turn this picture here into a
definition now, and then we can use it to
make our program simpler.  So, the
definition we're going to have is,
if we have some Maybe value, feeding into,
or in sequence with, some function f. So,
the operator we're defining here is
this funny sequencing symbol, and we'll
back to that in a second. What we're
going to do, is a case analysis - we're
going to look at what the Maybe
value is - if it's Nothing,
we'll give back Nothing, and if it's Just
of x, we'll apply the function to it. Okay,
so we'll just captured the pattern, which
we've seen twice, by a definition now. So,
we have some Maybe value, then, or in
sequence with, some function f, and all
we're going to do is look at what the
value of the Maybe is - if it's failed,
we'll fail, if it succeeds, we pass the
result to the function f. It's just the

Turkish: 
ortak bir kalıptan soyutlama fikri
tanım olarak. Yani şimdi bunu kullanabiliriz
programımızı basitleştirecek tanım.
Öyleyse, bir zamanlar değerlendiricimizi tekrar yazalım
tekrar. Tip aynı kalacak -
bir ifadeyi girdi olarak alır ve
Belki bir değer geri verecek
eskisi gibi. Ama tanımı gidiyor
Bu sefer biraz daha basit olmak. Öyleyse, hadi
iskeleti yaz. Öyleyse, eğer biz
bir değeri değerlendir, yapacağız
şey. Bir bölümü değerlendirirsek,
bir şeyler yapacağız. Bu yüzden ne yapmalıyım
temel duruma yazalım mı? Ben yapabilirim
Sadece n'yi buraya yaz, ama aslında ben
Bunu da soyutlayacağım - daha doğrusu
Sadece n yazmadan, ben gidiyorum
n 'nin iadesini yaz, gerçekten ne olduğumu
yapma biraz yan
tanımı, x'in iadesi
Sadece x ile aynı. Ve sonra biz neyiz?
bölme durumunda mı? Peki, biz
önce bir değerlendirme yapacağız - biz
x'i değerlendirecek ve eğer öyleyse
Başarılı, küçük dizimizi kullanarak
operatör, sonucu besleyeceğiz

English: 
idea of abstracting out a common pattern
as a definition. So, now we can use this
definition to make our program simpler.
So, let's rewrite our evaluator once
again. The type will remain the same -
it takes in an expression as input, and
it's going to give back a Maybe value,
as before. But the definition is going
to be a bit simpler this time. So, let's
write down the skeleton. So, if we
evaluate a value, we're going to do
something. If we evaluate a division,
we're going to do something. So, what do
we write in the base case? Well, I could
write Just of n here, but actually I'm
going to abstract that as well - rather
than writing Just of n, I'm going to
write return of n, so really what I'm
making is a little kind of side
definition, that says return of x is the
same as Just of x. And then, what are we
doing in the division case? Well, we're
going to do an evaluation first - we're
going to evaluate x, and then if that's
successful, using our little sequencing
operator, we're going to feed the result

English: 
idea of abstracting out a common pattern
as a definition. So, now we can use this
definition to make our program simpler.
So, let's rewrite our evaluator once
again. The type will remain the same -
it takes in an expression as input, and
it's going to give back a Maybe value,
as before. But the definition is going
to be a bit simpler this time. So, let's
write down the skeleton. So, if we
evaluate a value, we're going to do
something. If we evaluate a division,
we're going to do something. So, what do
we write in the base case? Well, I could
write Just of n here, but actually I'm
going to abstract that as well - rather
than writing Just of n, I'm going to
write return of n, so really what I'm
making is a little kind of side
definition, that says return of x is the
same as Just of x. And then, what are we
doing in the division case? Well, we're
going to do an evaluation first - we're
going to evaluate x, and then if that's
successful, using our little sequencing
operator, we're going to feed the result

Turkish: 
bir fonksiyona. Yani bu fonksiyon
sonuç alacak, n geliyor
Bunu değerlendirmekten sonra gidiyor
y'yi değerlendirmek. Yani, eğer y'nin değerlendirmesini yaparsak,
bu başarılı, besleneceğiz
bu bir işleve dönüşür. Ve burada
tekrar, lambda gösterimini kullanıyorum
hakkında daha önce bir video yaptık,
Şuna bir bakabilirsin. Öyleyse, eğer
bu iki şeyin ikisi de başarılı
n ve m olmak üzere iki değere sahip olacağız ve sonra
tek yaptığımız onlarla safediv'i aramak.
sonra braketleri kapatın. Yani bu program
Burada program eşdeğerdir hangi
İç içe geçmiş tüm davaları yazdık.
analiz eder. Ama hepsi bu soyutlandı.
uzakta şimdi - her şey biraz oldu
dönüş içine soyutlanmış ve
sıralama ve safediv. Yani bu bir
şimdi güzel program, ama ben hala değilim
Bundan tamamen memnunum. Orada
hala orada biraz karmaşıklık - biz
hala komik lambda gösterimini kullanıyor,
Hala bu komik sembolü kullanıyoruz.
Hangisini tanıttık? Belki yapabilirim
daha da basit? Peki, nasıl bir dil
Haskell size verir, özel bir gösterimdir
buna sahip programlar yazmak için

English: 
into a function. So that function is
going to take the result, n, that comes
from evaluating that, and then it's going
to evaluate y. So, if we do eval of y, if
that's successful, we're going to feed
that result into a function. And here
again, I'm using the lambda notation,
which we did a video about previously,
you can have a look back at that. So, if
these two things are both successful,
we'll have two values, n and m, and then
all we do is call safediv with them,
then close the brackets. So, this program
here is equivalent to the program which
we wrote, which had all the nested case
analyses. But, that's all been abstracted
away now - it's all been kind of
abstracted into return, and the
sequencing, and safediv. So, this is a
nicer program now, but still I'm not
entirely happy with this. There's
still some complexity in there - we're
still using the funny lambda notation,
we're still using this funny symbol,
which we've introduced. Maybe I can make
it even simpler? So, what a language like
Haskell gives you, is a special notation
for writing programs which have this

English: 
into a function. So that function is
going to take the result, n, that comes
from evaluating that, and then it's going
to evaluate y. So, if we do eval of y, if
that's successful, we're going to feed
that result into a function. And here
again, I'm using the lambda notation,
which we did a video about previously,
you can have a look back at that. So, if
these two things are both successful,
we'll have two values, n and m, and then
all we do is call safediv with them,
then close the brackets. So, this program
here is equivalent to the program which
we wrote, which had all the nested case
analyses. But, that's all been abstracted
away now - it's all been kind of
abstracted into return, and the
sequencing, and safediv. So, this is a
nicer program now, but still I'm not
entirely happy with this. There's
still some complexity in there - we're
still using the funny lambda notation,
we're still using this funny symbol,
which we've introduced. Maybe I can make
it even simpler? So, what a language like
Haskell gives you, is a special notation
for writing programs which have this

Turkish: 
bir çeşit form. Ve bu yapmak denir
notasyonu. Bu yüzden bunu yazayım
gösterimde, sonra geri döneceğiz
Tüm bunların monad'larla ne ilgisi var.
Yani, bu programı bile yazalım
daha basit bir form ve bu bizim olacak
son program Olarak bir ifade alırız
giriş ve belki teslim edecek
bize bir tamsayı. Ve temel dava olmaz
değişim, yani n'nin karşılığını alacağız. Fakat
özyinelemeli dava biraz olacak
daha basit, çünkü notasyonu kullanıyoruz.
sıralamayı kullanmak için bir kısa yol olarak
biz tanıttığımız operatör. Bu yüzden yapabilirim
diyelim ki, bir bölümü değerlendirirsem ne olurum
yapacağım ve bu anahtar kelime,
bu sadece size bir steno
tam olarak ne yazdık, o
özel bir şey değil, sadece steno
Sadece sözdizimsel şeker. Ne yapacağız
yapmak, sonucu almak n, sonuçtan
Başarılı olursa, x değerlendirmesinin. Sonra,
sonucu m alacağız, sonuçtan
Başarılı olursa, değerlendirme y. Ve

English: 
kind of form. And this is called the do
notation. So let me write this in do
notation, and then we'll come back to
what this has all got to do with monads.
So, let's write this program in an even
more simple form, and this will be our
final program. We take an expression as
input, and it's going to Maybe deliver
us an integer. And the base case will not
change, so we'll get return of n. But the
recursive case is going to become a bit
simpler, because we use the do notation
as a shorthand for using the sequencing
operator which we've introduced. So, I can
say, if I evaluate a division, what I'm
going to do, and this is the keyword,
which just gives you a shorthand for
exactly what we've just written, it's
not anything special, it's just shorthand,
just syntactic sugar. What we're going to
do, is take the result n, from the result
of evaluating x, if it's successful. Then,
we'll take the result m, from the result
of evaluating y, if that's successful. And

English: 
kind of form. And this is called the do
notation. So let me write this in do
notation, and then we'll come back to
what this has all got to do with monads.
So, let's write this program in an even
more simple form, and this will be our
final program. We take an expression as
input, and it's going to Maybe deliver
us an integer. And the base case will not
change, so we'll get return of n. But the
recursive case is going to become a bit
simpler, because we use the do notation
as a shorthand for using the sequencing
operator which we've introduced. So, I can
say, if I evaluate a division, what I'm
going to do, and this is the keyword,
which just gives you a shorthand for
exactly what we've just written, it's
not anything special, it's just shorthand,
just syntactic sugar. What we're going to
do, is take the result n, from the result
of evaluating x, if it's successful. Then,
we'll take the result m, from the result
of evaluating y, if that's successful. And

English: 
then, we will call safediv. And this is
our final program, and I'm much happier
with this one. I mean, it looks kind of
similar to the original program, a
similar level of complexity, but all the
failure management is now handled for us
automatically. The failure
is happening behind the
scenes with the do notation, and with
safediv, but we don't need to see that
when we're reading this program. This is
a much nicer program than the last one,
because we've kind of abstracted away
from a lot of the detail. So, you can look
at a program like this, and I've hardly
mentioned the word monads in the last
ten minutes, you can say what's this
actually got to do with monads? Well, what
we've actually done,
is we've rediscovered what's
known as the Maybe monad. The
Maybe monad is three things -
it's the Maybe type, or really the Maybe
type constructor, because it takes a
parameter. So you can have Maybe of an
integer, or maybe of a Boolean, or maybe of
whatever you like. And then it's two
functions - it's the function called
return, and it's the sequencing operator
which we introduced. And we can think
about what are the types of these things?
So what return does, is it takes a thing

Turkish: 
o zaman safediv'i arayacağız. Ve bu
son programımız ve ben daha mutluyum
Bununla birlikte. Yani, biraz benziyor
orijinal programa benzer
benzer düzeyde karmaşıklık
başarısızlık yönetimi artık bizim için ele alınıyor
otomatik olarak. Başarısızlık
arkasında oluyor
do notasyonuna sahip sahneler ve
safediv, ama bunu görmemize gerek yok
Bu programı okurken. Bu
sonuncusundan daha güzel bir program,
çünkü bir nevi soyutlanmış durumdayız
ayrıntıdan çok. Yani bakabilirsin
Böyle bir programda ve ben pek
Sonunda monads kelimesinden bahsetti.
on dakika, bunun ne olduğunu söyleyebilirsin
Aslında monads ile ilgisi var? Peki ne
aslında yaptık
ne olduğunu yeniden keşfettik mi
Belki monad olarak bilinir.
Belki monad üç şeydir -
belki türü, ya da gerçekten belki
yapıcı yazın, çünkü bir
parametre. Yani belki bir olabilir
tamsayı, ya da belki bir Boole
her ne seversen. Ve sonra iki
fonksiyonlar - adı verilen fonksiyon
return ve sıralama operatörü
hangi biz tanıtıldı. Ve düşünebiliriz
Bu tür şeyler nelerdir?
Öyleyse ne işe yarıyor?

English: 
then, we will call safediv. And this is
our final program, and I'm much happier
with this one. I mean, it looks kind of
similar to the original program, a
similar level of complexity, but all the
failure management is now handled for us
automatically. The failure
is happening behind the
scenes with the do notation, and with
safediv, but we don't need to see that
when we're reading this program. This is
a much nicer program than the last one,
because we've kind of abstracted away
from a lot of the detail. So, you can look
at a program like this, and I've hardly
mentioned the word monads in the last
ten minutes, you can say what's this
actually got to do with monads? Well, what
we've actually done,
is we've rediscovered what's
known as the Maybe monad. The
Maybe monad is three things -
it's the Maybe type, or really the Maybe
type constructor, because it takes a
parameter. So you can have Maybe of an
integer, or maybe of a Boolean, or maybe of
whatever you like. And then it's two
functions - it's the function called
return, and it's the sequencing operator
which we introduced. And we can think
about what are the types of these things?
So what return does, is it takes a thing

English: 
of any old type, a - could be an integer,
could be a Boolean, could be whatever you
like. And it converts it into a Maybe
value. So, in our case, this just took an
integer like five, and we return Just of
five. Okay, so that's all the return was
doing, it's basically just applying Just.
And what it gives you, is a bridge
between the pure world of values here,
and the impure world of things that
could go wrong - so it's a bridge from
pure to impure, if you like. And what
sequencing does, is it gives you a way of
sequencing things - so you give it
something which can fail, a Maybe a, and
then you give it a function that tells
you what to do with that a, if you
succeed - so an a to Maybe b. And then,
finally, what you're going to get back is a
Maybe b. Okay, and this is all that
a monad is essentially - a monad is some
kind of type constructor, like Maybe, or
List, or something else, as there's many
other examples, together with two functions
that have these types here. So, what we've
essentially done is rediscovered what's

Turkish: 
herhangi bir eski tipte, a - bir tamsayı olabilir,
Boolean olabilir, ne olursa olsun
sevmek. Ve onu Belki'ye dönüştürüyor.
değer. Yani, bizim durumumuzda, bu sadece bir aldı
beş gibi bir tamsayı, ve biz sadece döndük
beş. Tamam, tüm dönüş buydu
yapıyor, basitçe sadece Just'a başvuruyor.
Ve sana verdiği şey, bir köprü
Buradaki değerlerin saf dünyası arasında,
ve şeylerin saf dünyası
yanlış gidebilir - yani bu bir köprü
İsterseniz, saf olmayan saf. Ve ne
sıralama yapar, size bir yol sunar mı
işleri sıralamak - böylece ver
başarısız olabilecek bir şey, Belki bir, ve
o zaman ona söyleyen bir işlev verirsin
eğer onunla ne yapmalı
başarılı - yani a a Belki b. Ve sonra,
Sonunda geri alacağın şey bir
Belki b. Tamam, hepsi bu
bir monad esasında - bir monad biraz
Belki türden bir tür kurucu
Liste, ya da başka bir çok şey olduğu gibi
iki fonksiyonla birlikte diğer örnekler
Burada bu tür var. Peki, neyimiz var
aslında yapılan şey yeniden keşfedilir

English: 
of any old type, a - could be an integer,
could be a Boolean, could be whatever you
like. And it converts it into a Maybe
value. So, in our case, this just took an
integer like five, and we return Just of
five. Okay, so that's all the return was
doing, it's basically just applying Just.
And what it gives you, is a bridge
between the pure world of values here,
and the impure world of things that
could go wrong - so it's a bridge from
pure to impure, if you like. And what
sequencing does, is it gives you a way of
sequencing things - so you give it
something which can fail, a Maybe a, and
then you give it a function that tells
you what to do with that a, if you
succeed - so an a to Maybe b. And then,
finally, what you're going to get back is a
Maybe b. Okay, and this is all that
a monad is essentially - a monad is some
kind of type constructor, like Maybe, or
List, or something else, as there's many
other examples, together with two functions
that have these types here. So, what we've
essentially done is rediscovered what's

English: 
called the Maybe monad. What's the point
of all of this? I mean, what's the point?
We seem to have gone through quite a lot
of steps, to write in the end quite a
simple program. What was the actual point
here? So there's four points which I
would like to emphasize here. So, the
first point, is that the same idea we've
seen works for other effects as well -
it's not specific to Maybe, which
captures failure. The same idea captures
other kinds, or you can use with, other
kinds of effects like input/output, like
mutable state, like reading from
environments, like writing to log files,
non-determinism. All sorts of other
things which you think of as being
effects in programming languages fit
exactly the same pattern. So, monads kind
of give you a uniform framework for
thinking about programming with effects.
Another important point is that it supports
pure programming with effects.
I mean, Haskell is a pure
language - functions just take inputs, and
produce outputs, they don't have any kind
of side effects at all. But you need to
have side effects to write real

Turkish: 
Belki monad çağırdı. Amaç ne
bunların hepsinden? Demek istediğim, nokta ne?
Çok şey yaşadık gibi görünüyor.
Sonunda yazmak için adımların bir
basit bir program. Asıl nokta neydi
İşte? Demek ki dört puan var
burada vurgulamak istiyorum. Böylece
ilk nokta, aynı fikirde olduğumuz mu
diğer etkiler için de görülen eserler -
belki, belirli değil
başarısızlığı yakalar. Aynı fikir yakalar
diğer çeşitlerle veya diğerleriyle birlikte kullanabilirsiniz.
giriş / çıkış gibi etki türleri
değiştirilebilir durum
günlük dosyalarına yazma gibi ortamlar,
deterministik olmayan. Diğer her türlü
varlık olarak düşündüğün şeyler
dil uyumunda etkileri
tam olarak aynı desen. Yani, monads tür
size tek tip bir çerçeve vermek
Etkileri olan programlama hakkında düşünme.
Bir diğer önemli nokta, desteklediği.
efektli saf programlama.
Yani, Haskell saf
dil - fonksiyonlar sadece girişleri alır ve
çıktı üretmek, herhangi bir çeşidi yoktur
yan etkileri hiç. Ama ihtiyacın var
gerçek yazmak için yan etkileri var

English: 
called the Maybe monad. What's the point
of all of this? I mean, what's the point?
We seem to have gone through quite a lot
of steps, to write in the end quite a
simple program. What was the actual point
here? So there's four points which I
would like to emphasize here. So, the
first point, is that the same idea we've
seen works for other effects as well -
it's not specific to Maybe, which
captures failure. The same idea captures
other kinds, or you can use with, other
kinds of effects like input/output, like
mutable state, like reading from
environments, like writing to log files,
non-determinism. All sorts of other
things which you think of as being
effects in programming languages fit
exactly the same pattern. So, monads kind
of give you a uniform framework for
thinking about programming with effects.
Another important point is that it supports
pure programming with effects.
I mean, Haskell is a pure
language - functions just take inputs, and
produce outputs, they don't have any kind
of side effects at all. But you need to
have side effects to write real

English: 
programs. So, what monads give you is a
way of doing impure things, like proper
side effects, like input/output, in a pure
programming language like Haskell. Another
important point here, is that the use of
the effects is explicit in the types.
When I wrote the
evaluator which didn't fail,
it took an expression as input, and it
delivered Maybe of an integer. So, the
Maybe in the type is telling me that
this program may fail. So, this is the
idea of being explicit about what kind
of effects, or side effects, that your
programs can have in the types. And this
is a very, very powerful idea. And the
last thing is, it's a little bit strange,
but it's particularly interesting, it's
the idea of writing functions that work
for any effect - we might call this kind of
effect polymorphism. So, a simple example
of this would be maybe you have a
sequence of things, which can have some
effects, and you want to run them all one
after the other. You could write a
generic function, in a language like
Haskell which supports monads, which
would take a sequence of effects of any
kind, any monadic type, and it would run
them for you. So this is a very, very

Turkish: 
programları. Yani monadların sana verdiği şey
uygun olmayan şeyleri yapmanın yolu
giriş / çıkış gibi yan etkiler saf
Haskell gibi bir programlama dili. Bir diğeri
Burada önemli nokta, kullanımı
etkileri türlerinde açıktır.
Yazdığımda
başarısız olan değerlendirici,
girdi olarak bir ifade aldı ve
Belki bir tamsayı. Böylece
Belki de tipte bana bunu söylüyor
bu program başarısız olabilir. Yani, bu
ne tür hakkında açık olma fikri
etkileri veya yan etkileri
program türleri olabilir. Ve bu
çok, çok güçlü bir fikir. Ve
Son şey, biraz garip,
ama özellikle ilginç, bu
İşe yarayan fonksiyonlar yazma fikri
herhangi bir sonuç için - bu tür
etki polimorfizmi. Yani basit bir örnek
Bunun olabilir belki bir
bazı olabilir bazı şeylerin,
efektleri ve hepsini çalıştırmak
diğerinden sonra. Bir yazabilirsin
genel bir işlev, gibi bir dilde
Monadları destekleyen Haskell
herhangi bir etkisi bir dizi alırdı
tür, herhangi bir monadik tür ve çalışacak
onlar senin için. Yani bu çok, çok

English: 
programs. So, what monads give you is a
way of doing impure things, like proper
side effects, like input/output, in a pure
programming language like Haskell. Another
important point here, is that the use of
the effects is explicit in the types.
When I wrote the
evaluator which didn't fail,
it took an expression as input, and it
delivered Maybe of an integer. So, the
Maybe in the type is telling me that
this program may fail. So, this is the
idea of being explicit about what kind
of effects, or side effects, that your
programs can have in the types. And this
is a very, very powerful idea. And the
last thing is, it's a little bit strange,
but it's particularly interesting, it's
the idea of writing functions that work
for any effect - we might call this kind of
effect polymorphism. So, a simple example
of this would be maybe you have a
sequence of things, which can have some
effects, and you want to run them all one
after the other. You could write a
generic function, in a language like
Haskell which supports monads, which
would take a sequence of effects of any
kind, any monadic type, and it would run
them for you. So this is a very, very

Turkish: 
güçlü bir fikir ve Haskell gibi diller
Kütüphanelerde tür etkisi
çok kullanışlı olan fonksiyonlar. Yani,
temelde söylemek istediğim buydu. Sadece
Başa dönüyorum, bence fikir
monad'larla programlama
en önemli gelişmeler
son 25 dilde programlama dili
yıl - özellikle bunu buldum
büyüleyici. Biz sadece gerçekten dokunduk
Buradaki yüzey ve bilmek istiyorsanız
biraz daha, biraz yapabilirim
fiş - çıktığım yeni bir kitabım var
oldukça yakın zamanda, Haskell'de Programlama,
ve bunun özellikle bir bölümü var
Bu konuda, daha çok içine girer
detay. Ben sadece gerçekten dokundum
yüzey, yapmadığım birçok şey var
söyle, belki de bilmen gereken
bu şeyleri kullanarak gerçek programlar yaz. Yani,
kitapta bir göz atabilirsin 
Bunun hakkında daha fazla bilgi edinin. Bu bir
ilginç nokta, oldukça oldukça
öğrenen insanlar için bazı problemler
Haskell gibi diller, çünkü Haskell
insanlar doğru kullanma eğilimindedir
şeyler için matematiksel terimler ve bunlar
terimler genellikle oldukça yabancı

English: 
powerful idea, and languages like Haskell
have libraries of kind of generic effect
functions, which are very useful. So,
that's basically all I want to say. Just
going back to the start, I think the idea
of programming with monads is one of the
most important developments in
programming languages in the last 25
years - I find this particularly
fascinating. We've only really touched on
the surface here, and if you want to know
a little bit more, I can do a bit of a
plug - I have a new book which came out
fairly recently, Programming in Haskell,
and this has got a chapter specifically
about this, which goes into much more
detail. I've only really touched on the
surface, there's lots of things I didn't
say, which maybe you need to know to
write real programs using this stuff. So,
you could have a look in the book to 
find out more about that.  This is an
interesting point, it causes quite quite
some problems for people learning
languages like Haskell, because Haskell
people tend to use the proper
mathematical terms for things, and those
terms are often quite foreign to

English: 
powerful idea, and languages like Haskell
have libraries of kind of generic effect
functions, which are very useful. So,
that's basically all I want to say. Just
going back to the start, I think the idea
of programming with monads is one of the
most important developments in
programming languages in the last 25
years - I find this particularly
fascinating. We've only really touched on
the surface here, and if you want to know
a little bit more, I can do a bit of a
plug - I have a new book which came out
fairly recently, Programming in Haskell,
and this has got a chapter specifically
about this, which goes into much more
detail. I've only really touched on the
surface, there's lots of things I didn't
say, which maybe you need to know to
write real programs using this stuff. So,
you could have a look in the book to 
find out more about that.  This is an
interesting point, it causes quite quite
some problems for people learning
languages like Haskell, because Haskell
people tend to use the proper
mathematical terms for things, and those
terms are often quite foreign to

Turkish: 
programcılar. Ve oldukça bir neden olur
çok fazla zorluk - yani bazı insanlar var
aslında yapmamamız gereken görüşe sahip
monad terimini kullandık, belki biz
onlara etki denmeli ya da
bunun gibi bir şey. Yani, sadece daha fazlasını kullanın.
bir tür insan ya da tanıdık bir terim. Fakat
bu bir konudur. Ama ben aslında
bakış açısını, eğer biliyorsak
Bir şey için uygun terim, aramalıyız
bu bir şey ve kim
kullanıyorsanız sadece bu terimi öğrenmelisiniz.
Yani, olan bu, bir monad,
ve buna saygı göstermeliyiz
Bu fikri keşfettiği için matematikçiler
ilk önce
bağımsız olarak keşfedildiyse -
matematikçiler bunu keşfetti, almalılar
Bunun için kredi, ve ben çok mutluyum
monad kelimesiyle. Ancak, neden olur
insanlar öğrenirken bazı sorunlar
programlama dilleri, çünkü
biraz korkutucu ses ve çok daha fazlası var
gibi programlama gibi korkunç terimler
iyi. Bunların hepsi yerleşik.
Haskell gibi diller. Yani var
programlama için birçok kütüphane
monadik şeylerle - siz

English: 
programmers. And it does cause quite a
lot of difficulty - so there's some people
have the view that we shouldn't actually
have used the term monad, maybe we 
should have called them effects, or
something like that. So, just use the more
kind of human, or a familiar term. But
it is an issue. But I'm actually of
the point of view that, if we know the
proper term for something, we should call
it that something, and the people who
are using it should just learn that term.
I mean, it's what it is, it's a monad,
and we should kind of pay homage to
the mathematicians for discovering this idea
first, and not kind of reappropriate it as
if it was discovered independently - the
mathematicians discovered this, they should get 
credit for that, and so I'm quite happy
with the word monad. But, it does cause
some problems when people are learning
programming languages, because it does
sound a bit scary, and there's lots more
scary terms like this in programming as
well. This is all built into
languages like Haskell. So, there's
lots of libraries for programming
with monadic things - you

English: 
programmers. And it does cause quite a
lot of difficulty - so there's some people
have the view that we shouldn't actually
have used the term monad, maybe we 
should have called them effects, or
something like that. So, just use the more
kind of human, or a familiar term. But
it is an issue. But I'm actually of
the point of view that, if we know the
proper term for something, we should call
it that something, and the people who
are using it should just learn that term.
I mean, it's what it is, it's a monad,
and we should kind of pay homage to
the mathematicians for discovering this idea
first, and not kind of reappropriate it as
if it was discovered independently - the
mathematicians discovered this, they should get 
credit for that, and so I'm quite happy
with the word monad. But, it does cause
some problems when people are learning
programming languages, because it does
sound a bit scary, and there's lots more
scary terms like this in programming as
well. This is all built into
languages like Haskell. So, there's
lots of libraries for programming
with monadic things - you

English: 
don't need to define a lot of the
infrastructure, like Maybe, and return, and
the sequencing, for yourself - this is
kind of built in as libraries. You can
define your own ones if you want to, but
there's maybe kind of fifteen or twenty
monads which are just lying around
waiting for people to use. And if you
want to use multiple different monads
in your programs, maybe you need two
different kinds of effects, maybe you need
things that can fail, and you need some
state, there's ways of coping with that
kind of stuff as well. So, you don't need
to do all yourself,
it's mostly built in for you.

English: 
don't need to define a lot of the
infrastructure, like Maybe, and return, and
the sequencing, for yourself - this is
kind of built in as libraries. You can
define your own ones if you want to, but
there's maybe kind of fifteen or twenty
monads which are just lying around
waiting for people to use. And if you
want to use multiple different monads
in your programs, maybe you need two
different kinds of effects, maybe you need
things that can fail, and you need some
state, there's ways of coping with that
kind of stuff as well. So, you don't need
to do all yourself,
it's mostly built in for you.

Turkish: 
birçoğunu tanımlamanıza gerek yok
Belki gibi bir altyapı ve geri dönüş, ve
sıralama, kendiniz için - bu
Kütüphaneler gibi yerleşik. Yapabilirsin
istersen kendininkileri tanımla
belki on beş ya da yirmi var
sadece etrafta yatan monadlar
insanların kullanmasını bekliyorum. Ve eğer sen
birden fazla farklı monad kullanmak istiyorum
programlarında belki iki tane gerekir
değişik etki türleri, belki ihtiyacınız olabilir
başarısız olabilecek şeyler ve biraz
devlet, bununla baş etmenin yolları var
Bir çeşit şey. Yani ihtiyacın yok
Kendini yapmak için
çoğunlukla sizin için inşa edilmiştir.
