We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Computation expression in context - a history of the otter king

00:00

Formal Metadata

Title
Computation expression in context - a history of the otter king
Title of Series
Number of Parts
163
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
I heard that computation expressions are kind of like monads. I heard that monads are like burritos or space suits, and that they are pretty much magical. I also heard that they are monoids in the category of endofunctors... As a writer of code that all sounds awesome, and I want to know and understand (and I'm sure you do too) what those terms actually mean, and most importantly why we should care about them. What are their practical uses? So, in this talk we are going to attempt to do just that. Failure is possible, but the attempt is valuable. It's a lot to chew so make sure you had your tea/coffee.
Compilation albumDigital signalGame theoryMultiplication signTheoryContext awarenessCategory of beingGame theoryEvent horizonExpressionVideo gameGoodness of fitVideo game consoleTime zoneNeuroinformatikComputer virusMonad (category theory)Table (information)Computer animation
Pairwise comparisonOperations researchData conversionParallel computingMonoidFunctional (mathematics)Computer programmingMonad (category theory)Link (knot theory)Physical lawIdentity managementAssociative propertyInformationAlgebraic closureGame theoryRule of inferenceOperator (mathematics)Type theoryElectronic signatureFunctional (mathematics)WhiteboardMonoidOrder (biology)MathematicsProcess (computing)Stack (abstract data type)Interface (computing)Category of beingSound effectMonad (category theory)Context awarenessNichtlineares GleichungssystemTracing (software)Electronic mailing listVideo gameComputer programmingFormal languageTerm (mathematics)MereologyComponent-based software engineeringFunctional programmingImperative programmingScripting languageWeightCodeMoment (mathematics)Logic gateOpen sourceNoise (electronics)Right angleMultiplication signInheritance (object-oriented programming)Graph coloringIdentity managementOvalFilm editingLink (knot theory)Keyboard shortcutAdditionSoftware testingFocus (optics)Web pageRootGoodness of fitAlgebraic closureExpressionCASE <Informatik>Reading (process)Group actionParameter (computer programming)Connectivity (graph theory)Computer animation
MonoidAlgebraic closureIdentity managementAssociative propertyElectronic mailing listCategory of beingMonad (category theory)Abelian categoryOperator (mathematics)Electronic signatureMonoidType theoryEquivalence relationError messageAssociative propertyElectronic mailing listGraph coloringPhysical lawCategory of beingCodeParallel portRight angleResampling (statistics)Software testingBitCommutatorMathematicsRule of inferenceIdentity managementCASE <Informatik>Pattern languageGoodness of fitNormal (geometry)ResultantPower (physics)QuicksortShape (magazine)PressureClosed setGroup actionDifferent (Kate Ryan album)Algebraic closureFunctional (mathematics)Entropie <Informationstheorie>ForestMoment (mathematics)Transport Layer SecurityMappingMereologyFocus (optics)WeightData typeTorusMetropolitan area networkComputer animation
Menu (computing)Error messageDivision (mathematics)Core dumpCodeGame theoryNeuroinformatikBitKeyboard shortcutScripting languagePattern languageType theoryDivision (mathematics)Operator (mathematics)Computer configurationInterior (topology)CASE <Informatik>ExpressionFunctional (mathematics)ResultantWordMonoidDigital divideShape (magazine)Parameter (computer programming)NumberGoodness of fitMultiplication signMoment (mathematics)Right angleReading (process)Event horizonPunched cardTransport Layer SecurityPhysical systemSoftware testingCombinational logicGroup actionMereologyMappingDrop (liquid)HypermediaPoint (geometry)Computer animation
Interactive televisionRevision controlError messageIdentity managementExecution unitMonad (category theory)Regulärer Ausdruck <Textverarbeitung>SynchronizationPhysical systemCASE <Informatik>Order (biology)SubsetStructural loadBitNP-hardDifferent (Kate Ryan album)Multiplication signHand fanType theoryPresentation of a groupPoint (geometry)Event horizonNumberLibrary (computing)Set (mathematics)Line (geometry)Rule of inferenceSource codeException handlingComputer-assisted translationSoftware testingProcess (computing)WritingLetterpress printingVirtual machineGroup actionSimilarity (geometry)Cloud computingExpert systemAbstractionSound effectMonad (category theory)ExpressionFormal languageNeuroinformatikKeyboard shortcutContext awarenessMonoidFunctional (mathematics)TwitterImplementationNatural numberAssociative propertyCodeComputer programmingResultantDatabaseOnline helpMereologyError messageCategory of beingTrailJava appletMoment (mathematics)DataflowFormal verificationDirected graphFisher's exact testFilm editingPoint cloudArithmetic meanTouch typingComputer configurationRight angleRoutingGoodness of fitGodShape (magazine)PlanningService-oriented architectureFairness <Informatik>Programming languageWebsiteKnotRow (database)TorusDistanceSoftware developerFitness functionLevel (video gaming)Form (programming)Cycle (graph theory)Game theorySpring (hydrology)Computer animation
Transcript: English(auto-generated)
Hello. Good afternoon, evening, or whatever time zone you're actually alive in. So we're going to talk about computation expressions in context, a history of the arcane. So what that means is that I'm going to give you kind of like an intro to computation expressions.
So if you're hoping to learn about category theory or in-depth monadic structures, you're in the wrong talk, and you can leave now. Flip tables and leave going, oh, how dare you. This is a good time. Also, comic value for all of us.
Anybody? No? That's a shame. So my name is Andrea Magnurski, and I do all those things. Digital furnace games and bucket games are two companies that make video games for PC and console.
And Gamecraft Foundation is a not-for-profit that runs game jam events in Europe and North America for hope that we can get our places. So if you want to do that, you know, let me know. So a game jam, for those of you who are looking confused, or maybe that is just your normal face, I don't know, it's basically you make a game in a day, and you play it at the end.
And other people play your game too. So like a hackathon, but actually fun. So the name of my game is Onikira, Demon Killer, which means Demon Killer, Demon Killer. And we know, and we're okay with that. And this game is coming out on Steam.
Steam is like a marketplace for PC games. It's coming out in about a month, fully. Yay! Thank you, thank you. It's available right now on Early Access, and actually I think it's on the Steam sale.
So, you know, if you want to grab it, that's totally cool. And here I have to give you the disclaimer. I know you cannot read, so you're reading, right? I like interaction, because otherwise I get bored, and this is supposed to be somewhat comical,
but sometimes it doesn't happen that way. So, this picture is supposed to scare you. So, why am I talking about computational expressions?
So the game that I just told you about, that game is written in a game engine called Duality, which is an open-source C-Sharp engine that runs on OpenGL. That's the important part. It's a component-based game engine, and we added support for F-Sharp scripting.
We use F-Sharp for a bunch of other things, like builds and testing, which is great ways to introduce the language to your .NET stack. Hint, hint. So, I was doing a lot of F-Sharp scripts, but the problem is I was interacting with this very C-Sharpy,
imperative, more imperative than OUI kind of interface. That made my F-Sharp code not as nice as it could be, so I started to think about how do we deal with that? How do we deal with that impedance, I guess?
So, monads. I heard that monads are good for that stuff, right? Monads are good for dealing with side effects and stuff, so I'm going to read about it. I mean, what do you do when you need to learn something? You go off the Wikipedia, find out that that doesn't make any sense, and actually start searching for our stuff. So, this guy that is really cool with sandals, his name is Eugenio Moggi,
and he was the first one to write a paper about using monads in functional programming. So, I grabbed the paper. I thought, you know, first guy. I like reading papers that are at the start because generally they focus on the origin of the idea.
Obviously, he didn't invent monads, so I thought, well, you know, I'll get something out of it. So, I read the first page, and everything was good. And then I turned the second page, and I started seeing all these equations. I got really freaked out and went and moved on to the next paper, like most of us will do, but none of us will admit, right?
Whoops, that's the wrong one. So, then I found this guy. I was like, with that picture, I'm sure this guy is going to just get me, right? So, this guy's name is Philip Wadler, and he wrote these two papers on monads. One is called Comprehending Monads, and the other one is Monads for Functional Programming.
I chose one kind of randomly because it started with the lines, should I be pure or impure? And that just kind of, I was like, wow. It really touched my heart, right? So, this paper basically explains how to deal with, in Haskell,
how to deal with errors, exceptions, and tracing. So, all this stuff that in imperative languages are kind of easy and simple, or so we think it's easy to do the first time, and then you manage to really make your life impossible. So, how do you do it in a pure language like Haskell?
So, it tells you, it shows you bind, and it shows you also these monadic rules, and the category theory, and you start going, okay, so category theory, then three rules of monads, left identity, right identity, associativity,
I know that one, I remember that one from when I was like five. So, I was kind of confused, and then I got the visit from this author, like I think I was kind of asleep, and I just popped up and I see this guy, and he said, monads, eh, talk to the other king.
You can imagine how confused I was. I mean, an order turning up like that, I mean, what the hell is going on? And what are these laws? I mean, you know, that's kind of crazy. So, I was like, okay, there's a lot of mathematical context on all of this,
how do I think about it? And I thought, I remember from reading those papers that a monad is a monoid in the category of endofunctors, right? And I laughed like that because I had no idea what the hell that's not. So, I thought, okay, if I learn to think about what is a monoid,
maybe I'll get a clue about how to use this monadic stuff and not be so afraid of it. So, I thought, okay, why would I learn about monoids? Because I don't want to just go and do something for the sake of it. Although sometimes I do, but not this time. So, monoids allow you to compare an operation that will be a pair like add
or something that you do with two things, and you can do it with a list instead. Because that's kind of cool, that's very useful in programming, right? Yes, good, you have laugh, then you can say yes too. Another good thing is that you can, it's easier to parallelize, and you can do any programming or processing in an incremental way,
so you can split this stuff. These are things that I thought I would like in my toolbox, so I went ahead and tried. For a monoid to be a monoid, we have to follow these really complex mathematical rules. It's very scary. I know you're all going to be very afraid,
but I'm sure you can contain yourselves, I can see the struggle in you. So, you need the operation to be closure. So, what that means is if you think in terms of functions, you have, you know in F sharp or in Haskell, if you've seen the talk just before mine,
we were talking about type signatures of functions. So, in this first case, it would be that you have A and A and A. So, what that means is, for example, you will have a function that takes two parameters, like two ints, and it will return an int. All PG? Everybody's cool? We're all on board.
Nobody left behind. Cool. So, it's a closed operation. Good. Not too hard? I can deal with this. Identity. What that means is that if you have an operand, an operator, and they say, say for example, we have an addition as well, we say that one plus zero is one.
It's actually also called the zero operation. So, it's an operator that if you apply it to any operation, it will return the same result. Good, good. See, I'm checking if you're awake, because I know, I know. So, associativity. That means that we have some sort of operation we want to do.
We can group that in different ways, but not reorder it. There might be something there if you don't catch commutativity problems. So, this is a trick. There might or there might not be errors in my slides, and if you catch them, you're cool.
So, anyway, very hard. We have this closure, identity, and associativity. Very simple. Now we're going to apply it to a problem, right? Because we're tired of looking at this math stuff, right? And so, what I have here? Here, we're trying to do this. We're trying to add colors, add a list of colors, right?
So, I went ahead and I was like, I'm going to, I'm going to do this. I'm so cool. And I added this mutable operation, this mutable thing here. Not very good. Just in case you're not used to F sharp, I'm going to tell you. Color here is just a type with RGBA.
That's normal color stuff. So, you have red, green, blue, and alpha, which is transparency. And here, I've defined a function. See, we have the signatures there as well. When I hover over, you can see C1, C2. You can't see it there because you see it here. Sorry.
So, you can see the signatures that we were talking about. That it takes, okay, I'm just going to tell you. It takes a C1 that is a color, and a C2 that is also a color, and it will return a color. Yay! So, oh, this kind of has the right shape, right? But here, I'm doing this thing, a mutable.
And this has another problem. Say I want to parallelize this. Not very good, right? So, let's see how we can make it better. Okay? So, we could define a type called monoid, right? And that type has a neutral operation. Remember, we talked about neutral operation before.
Sorry, a neutral operator. And we defined the operation, and we say that that operation should have a closed signature. So, we're all here. When you're left behind, if I see you kind of sleepy, I will totally hit you up with, like, what did I just say?
So, you know. So, we have that monoid type definition. In here, we actually define the color add as using that type. There. And we define the neutral as an actual value, which would be zero, zero, zero.
When you're adding two colors, obviously, zero is the equivalent of black. Think about that, if you have to. So, the operation is add two, which we actually defined before. Here. So, we're using the same little thing there. Finally, we can define a bunch of colors.
In here, I define C1 and C2 and use neutral to do that. So, just some colors to add. And here, I'm doing that, which is much nicer, if you ask me, than this. I mean, okay, it's a contrived little example,
but you can see what we can do with it, which is nice, I think. The thing is, like here, we define the type for the monoid. I'm sure some of you might be thinking, I don't really need to do that to use monoids. And you don't. But this type signature actually gives you the power to do something extra that is very, very nice,
that if you're not doing it, you should. Which is, you can properly test that your laws that we set up for the monoid, remember, closure, identity, and associativity, are actually holding. So, property testing is a way to random test your code.
In this case, we're gonna get randomly generated, in this case, T's, and randomly generated A and B's. And I use this nomenclature here, the M and Z and plus plus plus, because that's the way it's generally shown in maths. So, in here, you can change the types,
your M and Z and plus, and change it for the monoids you're using, and ensure that you actually do that, because you know that if these rules hold, you can parallelize, you know what I mean. And that's, I think, very, very cool.
And it's simple. It's not complicated. The beauty of it is that we didn't have to follow the pattern of the monkey dance. We just did something quite simple, and we just need to know how to think about it. So, it's about the idea. And I think that's kind of cool. And you?
Anyway, so, there I was, thinking of just working this out. I just worked this out, right? I just worked this monoid stuff, and I was feeling good. And I thought, okay, because of the close operation, I can convert the pair, and because of the associativity,
I can do parallelization and incrementalization. And because of identity, actually this stuff is possible, because, for example, say you have an empty list. You need a, okay. So far, yours seems like, yeah, this all makes sense, holds, cool. And then something strange happened.
I get a text, and this is disorders, right? Sending a text is like, listen, I know you like pictures of otters, so this is my favorite picture of myself. Apparently, otters are really self-conscious. The king will help you with this monoid stuff, because, you know, you got the small nodes, so I'm sure you'll get the rest.
And I noticed that this otter, they have these pipes, right? Why do they have pipes? Do they need to put something together? I don't know. So, I go back, and it's like all confident, yeah, I'm going to get the small stuff. Ooh-wee! But that didn't happen. So, I started reading, and it's like, a monoid is a monoid, okay?
Mm-hmm. Monoid's like a burrito. Who heard that one? Cool. Think of monoids as you would think of about Legos, but you step on them and it really hurts. So, I was like, thanks, thanks for that. And then, then, I woke up the next day, I went to sleep and came back,
and I see this in the news, Irish news. A terrorized village by otters. And this is like real news. I didn't make it up, I swear. And look at this. See this guy running around from this little beast? And it reminds me of our seemingly irrational fear
of saying the M-word. What the hell? We call it the M-word. There's a whole word for it. Monoid's actually shorter to say the M-word, right? So, so, I thought, okay, let's try to crack this. Let's go with something simple. One of the most beautiful examples of a monoid
is probably the maybe. Then I'm sure you heard of, if you were trying to read about this, I'm sure you read like this maybe, some maybe stuff, maybe either some of those things, and you were like, yeah, thank you for that. That's really helpful. So, in this example, I have code like this.
I was reading, so when I was doing my game stuff, I have a bunch of code that looks like this. I do scripts, so I have to check. Okay, does this bit of script return null? Yes, no. And if yes, I can do something else. And if yes, I can do something else. So this pattern is common.
The operation in this case in the example is a little contrived because why would you need to divide four numbers ever except that one time that you probably have in mind and that it's really good, but I didn't think about it just yet. So this one, so when here we have, can we all follow this code? I need yeses or nos, yes? So in here, divide, when everything's cool,
and then we divide everything. Please note the parenthesis here, how we divide the first thing first, then we divide the rest. Sorry? You're pointing to something we cannot see. That's good, I'm pointing here, but you can't see it. That's good. So I point here. So note the parenthesis here on how we're actually doing this stuff, right?
So we're dividing a and b first. The result of that is divided by c. Cool? So thank you for that, mister, your name. So okay, now let's try to use a moment, okay? So first step, we'll extract the core, the bit,
the repetitive bit, and see, this has the same shape. Ah, pointing at the wrong place. This has the same shape than this stuff here, the stuff that repeats, right? Then we create this type, okay?
This is when it gets a bit heavy. This one, it's got the question mark because here we're gonna start using a computation expression, which is just syntactic sugar, actually. You could write it yourself not this way, but I'm gonna do it this way because we're talking about computation expressions and it's probably better. So in this, we define a maybe builder
and we have an operation called bind and an operation called return. The bind has a value and a function and when you are on the pattern matching, you'll notice that you actually run the function. You do func value.
This is the stuff here, in case you are wondering. And the interesting thing is that that function will return the same type as here in none. In this case, we're using an option, so we will return an option of int in this particular case. And don't worry, we'll look at it a little bit more.
So we have this type and the way we will use that is that we'll use a computation expression here and we will call the divide function that we defined a little bit before as the simple normal divide and it will take two parameters that are defined here.
So the divide we defined before, all good. When we return this x, that x is an int as well, so it returns an unwrapped value and we can finally divide them all and have a return z. Which is pretty, pretty cool.
So, what does the bind do? Okay, we'll go here. We'll try to look at it a bit more. Okay. Who looks at this and thinks, even if you don't know exactly how it works, do you know what it will return?
Yes, no, no, just say no. No, okay, a few no's. Okay, so this maybe is basically, when this happens, the divide, it's calling the divide function that we defined,
sorry, here. So divide is quite simple. So we know how the division happens now. And when we define this maybe builder, it's gonna, because it takes a function as a parameter,
this function is the same function as here. So this let with a bang is actually what is calling bind. So that's like the only syntactic, sugary, magically bits that are happening. We're not calling explicitly bind, but we're calling it because we're saying let's bang.
So even if you know just that, you can guess very quickly that this is gonna be the result of dividing all of those things, which is very helpful. So the bind takes the wrap value,
bind takes the wrap value, unwraps optionally applies the function, so here we're doing the option of apply the function, and if you can't apply the function, you don't. And then always returns a wrapped value. And I keep using this wrap, and not because I'm wrapping,
it's because you have this way to deal it. In this case, the wrapping is called option, which is a native type in F sharp. And, yeah.
So, bind applies, and returns converts to wrap, which is kind of what we said before. Is anybody kind of confused by this at all? Yes? Okay. I'm gonna show you something.
That's my intention. So, we have some code. Oh, okay, all the code that I've shown here is available on my website, and there's also a bunch of examples of different monads and monoids
that you can check yourself. So, we can run any of those. So, this is the example we just had before. But there is another example that can be very good. And then, and that is around here somewhere.
Okay. So, in the example we did before, we were just piping kind of the same thing. We were dividing, getting a number, dividing, getting a number. But what if you need to do different things? Then, we can do stuff like this.
This is an example out of, straight out of F sharp for fun and profit. If you like F sharp, this is a great source of knowledge and stuff. Scott is sitting there. I hope he's not going like, oh my god, what is she doing? Which is likely what is happening. So, in here, we have a similar thing.
I'm showing this because I'm thinking perhaps something that is more DB related might hit closer to home for some people or not. I don't know. So, in here, we have an either builder. So, this one is slightly different because in the maybe we saw before, you had a success path, and the other one was like, nope, nope. I like going with nope because it's actually,
nothing has gone on. In this case, you can do something with the error. So, you're going to see a very similar shape. We have a bind and a return. And you have a success case in which you're not only doing the success, but you're also tracing, which is something you might want to do. And you have the error.
And you can actually return something out of it. So, say for example, you want to say, you're doing this example and you're doing customer order something else, but you never found the order. Or the customer, maybe you were searching it by name and then he decided that his name is going to be different because Ryanair decided to charge him more for a name.
This is a real story, by the way. So, yeah. So, you don't know. So, you can trace about what's going on. So, you have again, in this case, the wrapping type is still an option, right? And...
Here we're doing very similar stuff to before. The definitions of these methods are basically... If you... They are super simple. I just... I don't know where they are. Go to the definition. Big definition. Go to the definition. Please. Cool. So, the definitions of...
In case you're wondering, oh, what's going on? It's just we're doing mock methods just for the crack, okay? So, what is going on in this? Is that in here, because we're sending Alice as a parameter, here this will return something because we have a customer ID,
this will return something. In this order, it's not going to find that and it's going to fail. And we call this either builder activity result because we're dealing with an imaginary database that is actually just a mock. I don't know if you're happy with this or if this example helps. I do hope so.
Questions are always welcome, but otherwise I'm going to just keep going. No, that's not one. So, magic illusion, Michael. So, I'm going to assume that we got, maybe, and that we got the result, which is actually just a very different thing. And I'm going to proceed, too. Oh, yeah.
This is another thing. Remember we were property testing, we were property testing the monoids? Well, it turns out, remember we were talking about those monad rules that we didn't get. Well, I actually think understanding them at this point is not very useful, but the good thing is that, say you want to write a monad and want to find out if maybe they are correct or not,
and that wasn't a pun, you can use property testing to verify that. This is just another way to write property testing. So, fs-check is actually the name of this library, and in here we're checking for associativity and whatnot. In here, see for example, I like this one because they're kind of more clear. This is how you group stuff.
So, in this example, that comes straight from f-sharp x, which is a library with loads of monads. There's a bunch of different monads, like well-known monads available, and that's why they have names like maybe, either, or monads that I can't think of.
Most of them are there with not a lot of documentation, but a lot of code and verifiable code, which is very, very nice. Also, if you're not happy with something that is there, you can just ping Mauricio Schafer online. I'm sure that if he watches this recording, I'm sorry. I apologize in advance.
I owe you something. I don't know what it is. You can just go and find all this code and read it, because mostly you can follow it. It's not magic. It just takes a little bit of time. And that brings me to actually one of the points that I think are generally lost
when you find these millions of myriads of tutorials, which is this stuff takes time, and sometimes it doesn't pay off immediately, but it's really worth it. The first reason why it's worth it is because we have a common language
to talk about different programming languages, and the ideas are similar. When you generally talk with Java and C Sharp developers, it's like they don't want to talk to each other for some reason, and this is coming mostly from personal experience. But there's so much in common. Why not share the knowledge? If we have a common language
to talk about how to deal with side effects, calling them monads seems appropriate to me if they are a monad. Calling them monads seems appropriate to me if they are monads. Now, this is my opinion. Not a lot of people seem to share it, but hey, I think it's valuable, and I think you should think about this and discuss it online or offline.
The other reason why this is cool is that if you're trying to keep your code pure, you know, again, previous talk the guy was saying, hey, purity is cool, and it is really cool. Say you want to try to keep the purity of your code and not use mutable everywhere and all that stuff. Monads is the way to do it. How to deal with side effects, that's pretty cool.
So that's kind of part of my rant, which is good. So that brings me to computation expressions, and this is another one of those things that really irks me, and the first time I read this, I'm honored to have Tomas Petruschek here in the audience
because I read from his paper, and I was like, or actually the first time I read it was in a tweet. It's like I'm so annoyed or something that people keep calling monads a computation expression, and they are not one-to-one. And so now if anybody has like in-depth questions, I can just redirect to him. I can do a monad to redirect really difficult questions.
See what I did there? Anyway, so the point there is that computation expressions are a feature of a beautiful language. The most important thing there is that although you can implement monads with computation expressions, not all of them are, right?
So let's just remember this and, you know, move on. So what is a computation expression? It's basically the capability to do this bind and return, but you know the way we had led with a bang? Well, you can do four, you can do try, and all different natural F sharp language stuff,
but within the context of the computation. So when you read it, you can kind of guess what it does even without knowing exactly how you did it. So syntax matters, right? And I'm going to disagree, but not really,
with Yancui this morning. He was like, the syntax doesn't matter when you're learning, but when you're trying to work, then I agree with Yancui again, and when I say visual stuff and your brain having to process ideas, the better the syntax it is to illustrate that, the better.
So with this, you can deal with side effects in a kind of idiomatic, beautiful way, and with those squiggly lines telling you there's something strange happening here, so that's good. So you might be wondering, oh, what is this new thing? Isn't it new, cool thing? No, not really. 2007, they were implemented.
They are in the F sharp specification, and abstract computation, handling of effects. So this is exactly what they had in mind. And I think if I read well in Expert F Sharp, the book, apparently they discussed with the creators of Haskell,
like Don Sime, F Sharp designer, and all members of the committee, and Haskell designers, they all kind of got together and said, hey, would it be a good idea to call this monads? And they came up with, nope. They just call it computation expressions because they thought it was less, maybe scary,
but perhaps less feelings attached to it and more about what it actually does. Some examples of computation expressions, it's like the beautiful async workflow. So if you use async in C sharp, you probably cried a little bit because you thought you were stupid.
It's not you all the time. Sometimes it's me, I don't know. It's actually somewhat easy to shoot yourself in the foot with C sharp async, and this is not a criticism. I don't hate C sharp or anything. This is just, sadly or thankfully, better implemented in F sharp.
I don't know how to say that without hurting anybody. Now, the other beautiful thing is Embrace. So let's say you want to do a computation in the cloud, and you don't know how to do it. Well, that's kind of nearly doesn't matter because we have Embrace, right?
So Embrace is a library or a set of libraries implemented by these awesome guys in Greece. I don't know how because, I mean, beach, clouds. Anyway, that's a bad joke, sorry. They invented this thing.
So what do you think is going on here? Except Eric, you can't say that. What do you think is happening here? Volunteers get a free drawing of a cat. No, no takers. So that cloud computation expression, right, will go off and create a cloud, a machine for you.
It will do this very difficult job of printing this string, and this machine name is going to be a different machine that is not your machine. It's somewhere off in the distance, and that's it. You don't have to do anything. I mean, you have to say you need this library,
that you're going to use it, you have to have an account with Azure, but this will actually, that's the whole thing. I mean, of course, you can do more complicated things to print a string, but God, that's pretty amazing. At least, I mean, maybe I'm not explaining it right. Maybe, I don't know.
Maybe you're just in awe, but I can't see you because these lights are really, really bright. So that's just a subset of what you can do with computation expressions. If you're kind of going like, hey, that's not that hard, that's exactly the way I want you to live because I want you all to, whoever didn't read the Wadler paper or didn't play with this,
to go off and try it because it's not that hard. But be prepared to be overwhelmed by how ignorant you can be because you read and you're like, oh, okay, I kind of get this. Then there is like 50 million more things that you don't know about that the very smart people implemented for us, but this is not great.
Great ways to solve problems. So that's where the order king came. I was like, this order, what the hell? Well, he was telling me that we should stop asking about what monads are
because the important thing is to slowly understand it's not a thing, it's all these things that slowly come together in your brain. There's no what is a monad. It's just think about it and it comes. And this is probably the reason why you have all these tutorials about burritos and Legos
is because it's really hard to explain in one way. Maybe I can explain one particular case or two, but it takes time to, you know, get comfortable and maybe you don't get comfortable actually. For those of you who are fans of Serenity, I found a picture of the order king in his human form,
you know, just saying brown coats for the win. So, oh yeah, don't forget to vote. I hope you enjoyed the session. There's many, many more sessions to come. The very, very type loving Mark Seeman is going to follow up.
I highly recommend his talk, but also his courses are amazing, a great way to learn. Jose Valim, the creator of Elixir, is also going to be talking to us. Jeremy Chasing, he does some crazy presentations with events sourcing and functional.
And Mattias Vanderwinder, if you've never seen his presentations, you're going to be totally blown up. I actually can't fit everyone I want to show because the track is so good. So I hope you do that. And well, that's kind of all for me. Thank you very much.
And if you have questions, do you have any questions? I promise not to monad redirect all this stuff. I will just do it sometimes. No? Okay, I'll be around and thank you.