>_Programming podcast with Minko Gechev

Episode #3 Partial Application (not Currying)

Today we'll discuss partial application and currying. By the end of the episode, you'll understand what these two different concepts are how they are different from each other, and where you can apply them in practice. In between the episode, we'll also talk about the brilliant computer scientist Haskell Curry, and we'll mention the Curry-Howard isomorphism.

Today we'll discuss partial application and currying. By the end of the episode, you'll understand what these two different concepts are how they are different from each other, and where you can apply them in practice.

In between the episode, we'll also talk about the brilliant computer scientist Haskell Curry, and we'll mention the Curry-Howard isomorphism.

Here you can find additional resources:


hello today. We're going to talk talk about partial application so in fact the episode is called partial application. Not carrying this intention because there is a slight difference between partial avocation vacation and I want to clean up the difference also on top of that. We're going to talk about some very personal details from the life of hostile Carey three still stay tuned before going any further I would want us to define a concept called the era t of a function is a number. We're of arguments that it accept that. So for example if you have the function at which accepts the arguments a B and C. And it's just sounds awesome together. The Eric dysfunction at is going to be three so the definition of partial application you just a functional transformation which accepts a function with certain eighty and returns another function with lower already. That's it we have the function at. We can preview. Its first two arguments A and B with. Let's say the numbers wanting to so if applied partial application this way we're going to get another function auction which just accepts the argument t whilst we pass see we are going to get the final result of the function and if we let's say set st two three we're we're going to get six Indians. That's so in fact. This is not an extremely like crucial pattern or transformation that you're going to use daily I mean you can can achieve the results in your daily life you can live without it but sometimes it helps rights very clean and difficult. I often think of the partial application of a function Kim as the builder potter from the object oriented programming. Because you're building some kind of functionality. All like overtime by by prefixing some of its values have used partial application quite a few times probably most commonly used as for adding listeners. Let's suppose that we. We want to adjust at different quarterbacks for a certain events to a particular donald so we can create a function coats out. This say which accepts three different arguments. Eric sets the event that we're interested in is accepts. Dome note a callback so we can evolve this function many different times but if our first two arguments repeat very often we can express this for kill slightly different way. We can implement our at listener function which accepts only two arguments. This time don't know that we want to achieve and listener too and the events name. We can just return another function which is first argument except the callback that we want to associate for this particular event for domino that we have passed to our at this center function. That's it now. We can invoke our function at listener only once which the Donald in order the event were interested in and this is going to return a new function. That just accepts a callback so we can invoke only return function multiple times in at Multiple Book Kovacs for this particular event. Another use case is when you have to pay for a very heavy computation on top of only only subset of the arguments of the function. This way you can perform this computation. Only once entered another function which just accepts that the other arguments on top of which you have to perform on which lightweight computation so this pattern is extremely applicable when you have duplicated arguments for function that you need to pass over again now. Let's talk a little bit about Curry Inc.. Think so often people use currying and partial application interchangeably. And that's not terrible mistake. I mean they're very close conscious but they're slightly different with caring. For example we're going to accept a single function again from a certain area and we're going to return an error a set of functions. Basically we're going to get a set of functions where each individual one of them has already what this means that in our for example at with a function with three arguments. We're going to get one function which accepts a after it is going to return another function that exempts be and finally we were going to get a thir function which accepts see and whilst we invoke this chain of multiple three times pretty much. We're going to get the final result result of the concept of current originally introduced by goodluck. Prager who is a German philosopher logistician and a mathematician later on this concept was further developed by Mosa. Shelving kill like shopping. Sounds extremely German to me. Well does turn out to be Russian. Russian mm-hmm logistician and a mathematician whose very famous with the invasion of combinatorial logic. I'm going to talk a little a little bit about commentary. Logic Indiana Indiana this show. You might be wondering if this was hurt or developed by shopping kill. Why are we calling it curry? Is there a guy called curry. Yeah those this guy's cool haskell curry you may recognize his first name as well there are a lot of folks who think that he invented haskill. Well no that's just his first name some our folks invented Haskell later on and they wanted to call the language Husky because of all the fantastic contributions that haskell curry made to functional programming wink hostile Theresa Guy who started initially medicine. He started studying this in Harvard University and later on figure out that he was more interested in Calculus From Calculus later on he got introduced to the work by more shopping. Kill and he got really passionate about community logic. He got so passionate about community logic. That's this branch of math later. On his part the famous career Howard ISM refusal which shows a correspondence between programming languages and mathematical logic. You might have also heard us as propositions as types there is a fantastic told by Phillip Waller from strange loop where he goes well in a lot of details there. Communitarian logic did not Only inspire career hours him. which was this close fantastic relation between math and programming? He also is part and entire like like Trent. In programming tacit programming. It is also called point free style of programming where we are writing functions without specifying their arguments. I know exactly exactly what you're wondering right now. Well these I was wondering this thing when I heard of that shelf and kill was the first invented current. Why are we calling concurring incurring? Why isn't it named after Moses Shelf Inc Yo who invented also the competitor e logic? Imagine if we had to call it shopping kids ation instead. Well for functional programmers this decision to call it current or savers may hours a day in the today's salutes. We took a look at a couple of concepts. We first introduced the concept of authority which is just the number of arguments. That's a certain function. Except that's right after that. We talked about the functional transformation cold partial application where we're feeling a set of arguments in a function which is extremely applicable when we offer have to evoke function with a certain duplicated arguments or if we have to perform a very heavy computation only on a subset of the functions arguments. Right after we discussed currying and how it differs from partial abrogation we ended the show by talking kink about things that the commentary logic inspired which is the tacit style of programming or the point. Three programming as well as the Curry Howard ISM refusal. which does this fantastic beautiful equivalence between Mathematica warwick and programming languages for all of these stinks? I'm going to post links on Thursday's episode peach. Thank you very much to learn about not the episodes. You can follow me on twitter at him get you. The list of resources and recordings is available at podcast dot M. dot com. Thanks for listening.