Lesson 14 of 55
10 mins readPython Currying & Partial Function Application
In Plain English
In Haskell, multi-argument functions are curried by default. Passing fewer arguments than expected returns a new specialized function with the remaining parameters.
Deep Dive: How It Works
Currying Concept: f x y is actually (f x) y. Calling add 10 returns a new function (Int -> Int) that adds 10 to whatever it is passed.
Partial Application: Pass some arguments to create specialized utility functions without boilerplate lambdas.
Sections: Partially applying infix operators: (+10), (/2), (2^).
Core Rules to Remember

All Functions are Curried: Multi-parameter functions are chains of single-argument functions.

Operator Sections: (> 100) is a function that checks if a number is greater than 100.
Live Interactive Example
Hit Run Code to see it livePartial Application and Sections
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Output Console
Click "Run Code" to view the rendered output.
How it works: double is formed by partially applying multiply with 2.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Create Triple Function with Partial Application
Define `triple = (* 3)`.
Print `"Triple 9: "` followed by `show (triple 9)`.
1
2
3
4
5
6
7
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.