Study resource
Functional programming paradigm study guide
Study Functional programming paradigm with curriculum-aligned Study Guide resources, practice links, and exam-focused support.
At a glance
study guide
Resource type
Topic
Functional programming paradigm
Study guide overview
Deeper Study Guide: Reasoning About Functional Types and Function Operations
Use this guide to connect notation with the underlying mechanisms of domains, co-domains, first-class functions, application, partial application and composition.
1. Read a function type precisely
Start with the arrow notation. In
f: A → B, identify the domainAand the co-domainBbefore considering any example. The domain is the set from which inputs are chosen. The co-domain is the set from which outputs are chosen. The specification does not require that every co-domain value is returned, so an answer should say that the co-domain contains possible output values rather than claiming it is exactly the set of outputs.A useful exam check is to ask: “What kind of object can be supplied, and what kind of object can be returned?” For
f: integer → integer, one integer is supplied and one integer is returned. Forinteger × integer → integer, the input is a pair of integers and the result is one integer. This explains whyadd(3,4)can be described as taking two arguments informally while its type treats(3,4)as one pair-valued argument.2. Explain first-class status using consequences
A function is first-class when it can be used in the ways described for first-class objects. It may appear in an expression, be assigned to a variable, be supplied as an argument, or be returned from a function call. When answering a question, do not merely state that functions are “special values”; connect the definition to one or more of these permitted uses. Partial application is an important example because supplying an argument can produce another function.
3. Trace partial application carefully
For a two-argument function such as
add, use the sequence:- Begin with the curried view
add: integer → (integer → integer). - Apply the first integer, for example
add 4. - Recognise that the result is a function of type
integer → integer. - Apply that returned function to another integer.
- The final result is an integer, representing the second integer added to
4.
The brackets may be dropped, so the same type can be written
integer → integer → integer. The important reasoning is that one argument is supplied after another; after the first application, the result is still a function.4. Trace composition in the correct order
For
f: A → Bandg: B → C, the output type offmatches the input type ofg. Thereforeg ○ fis valid, has domainAand co-domainC, and appliesffirst. Withf(x) = x + 2andg(y) = y³, first calculatef(x), obtainingx + 2. Then use that result as the input tog, obtaining(x + 2)³. Reversing the order would describe a different operation and should not be written as the same composition.5. Self-check questions
- In
f: A → B, which set supplies inputs and which set supplies possible outputs? - Why can a co-domain contain values that are never produced?
- What four uses demonstrate that a function is first-class?
- Why is the input to
integer × integer → integerdescribed as a pair? - After applying the first argument in
integer → integer → integer, what kind of object remains? - In
g ○ f, which function is applied first, and why must the intermediate types match?
A strong answer should use the notation, state the order of operations, and distinguish a returned function from a final data value.
- Begin with the curried view
Ready to practise?
Choose your next step
Use the study guide for understanding, then switch into an active revision mode.
Related topics
