Functional Programming Skills
Functional Programming as a Set of Skills
Functional programming is often introduced through definitions: programming with pure functions, avoiding mutation, or treating functions as values. However, definitions can become confusing because different explanations emphasize different features.
A more practical approach is to understand functional programming as a collection of skills. Functional programmers tend to practice certain ways of thinking more frequently than programmers using other paradigms. These skills are not incompatible with object-oriented programming or other approaches. For example, object-oriented programming may emphasize encapsulation and object-oriented modeling, while functional programming may emphasize immutability, higher-order functions, and separating effects from computations. A software system can combine skills from several paradigms.
Five especially important functional-programming skills are:
- Distinguishing actions, calculations, and data
- Working effectively with immutable values
- Using and creating higher-order calculations and actions
- Modeling data effectively
- Designing functional architectures
The skills build on one another. The first skill helps identify how code behaves. The second controls how information changes. The third allows behavior itself to be manipulated. The fourth organizes information for practical use. The fifth applies these ideas to entire software systems.
Skill One: Distinguishing Actions, Calculations, and Data
The foundational functional-programming skill is being able to look at a program and distinguish among actions, calculations, and data.
These categories matter because they have different levels of predictability and different testing requirements. A calculation can usually be understood from its inputs and outputs. An action depends partly on when it occurs and how it interacts with the outside world. Data represents information rather than an ongoing process.
Calculations
A calculation is a computation from inputs to outputs. If the same inputs are supplied, the same output is produced, regardless of when the calculation runs.
For example, adding two numbers is a calculation:
2+3=5Running the addition now or later does not change the result. In many programming languages, calculations are implemented as pure functions, meaning that they do not depend on changing external state and do not cause observable side effects.
However, a calculation does not have to be represented by a function in every language. An arithmetic operator such as + can be a calculation even though it is written as an operator rather than as a named function.
Calculations are relatively easy to:
- Test, because their results are determined by their inputs
- Reuse, because they do not depend on a particular moment
- Reason about, because their behavior is stable
- Rearrange, because moving them does not usually change their meaning
Actions
An action is something whose result or effect can depend on when it is performed. Actions interact with changing circumstances, such as the current state of a system or the outside world.
An action might involve reading or changing a mutable value, communicating with another system, or performing an operation whose result depends on timing. An action may be represented by a function, but it is not necessarily a function in every language.
For example, an increment operation such as ++ is different from ordinary addition. Addition calculates a new result from values. Incrementing changes something, so its meaning depends on the state of the value and the moment when the operation occurs.
The key issue is not merely the syntax. The important question is whether the operation is stable and repeatable or whether its behavior depends on time and context.
Data
Data is information represented in a form that can be stored, passed around, examined, or transformed. Examples include a number representing a salary, a record representing an employee, or a larger structure representing a company.
Data is generally easier to work with than actions because data does not perform an operation merely by existing. It can be inspected and passed to different parts of a program without automatically causing an effect.
Why the distinction matters
Calculations and data are usually easier to manage than actions. Actions require special care because several questions become important:
- When should the action run?
- How many times should it run?
- What happens if it runs too early or too late?
- What happens if it runs more than once?
- How should failure be handled?
Because actions are harder to control, functional programming generally aims to keep action-oriented code small. More of the program’s logic can be moved into calculations, where it is easier to test and reuse. The actions then coordinate those calculations with the outside world.
A central functional-programming discipline is to identify which parts of a program are stable computations, which parts are information, and which parts have effects that depend on time or context.
This separation does not eliminate actions. Software must still interact with the outside world. Instead, it limits and isolates the difficult parts so that most of the system can be handled as predictable calculations and data.
Think About It
A program calculates an employee’s new salary and then saves that salary to a database. Which part is a calculation, and which part is an action? Why might the calculation be easier to test independently?
Skill Two: Working with Immutable Values
The second major skill is learning to work effectively with immutable values.
An immutable value is a value that cannot be changed after it has been created. If a different version is needed, the program creates another value rather than modifying the original.
Immutability in everyday life
People already use systems for preserving information permanently. Physical records may be placed in filing cabinets, protected in fireproof boxes, or created with archival-quality materials. Organizations may also establish rules such as:
- Only certain people may write on a record.
- A completed record may no longer be edited.
- A record may be stamped as checked or approved.
- A finalized document may be preserved as an authoritative version.
These practices exist because changing a record can destroy information about what was previously true.
Computer memory, however, is commonly mutable. A program can overwrite a value with a new one. This is convenient, but it means that the program must deliberately recreate the discipline of preserving information.
That discipline may be provided by:
- The programming team’s practices
- The programming language
- The database
- A combination of these
Functional programming places particular importance on developing the ability to work with immutable data rather than changing values freely.
Creating new versions
Working with immutable data often means creating copies or new versions of existing structures.
Suppose a company is represented by a structure containing employees, and each employee has a salary. If one employee receives a raise, the original company value remains unchanged. A new company value is created that represents the updated situation.
The conceptual process is:
- Preserve the original company value.
- Create a new version of the affected employee.
- Create a new company structure that refers to the new employee version.
- Preserve all unaffected information in the new structure.
The important point is that the old version remains available. This makes it possible to reason about what the company looked like before and after the change.
Nested immutable data
Nested structures make immutability more challenging. A company may contain employees, and employees may contain salaries. To change a salary deep inside the structure, the program must produce a new path through the structure.
For example, giving one employee a raise involves creating a new representation of that employee and a new representation of any surrounding structure that must point to the new employee. Giving every employee a raise requires applying the same kind of transformation throughout the company structure.
The skill lies in knowing:
- Which parts need new versions
- Which parts can remain unchanged
- How to preserve the original nested structure
- How to make the updated structure represent the intended change
Immutability therefore requires more than merely avoiding assignment. It requires a way of thinking about change as the creation of a new state rather than the destruction of an old one.
Why immutability is useful
Immutable values make a program’s history easier to understand. A value does not silently change while another part of the program is using it. This reduces the possibility that one part of a program will unexpectedly affect another part.
Immutability also supports the distinction between data and actions. Data can be passed around safely because simply passing it does not alter it. Changes become explicit transformations that produce new values.
Think About It
If a program changes an employee’s salary by modifying the existing employee record, what information about the previous salary is lost? How would creating a new employee value preserve that history?
Skill Three: Using and Creating Higher-Order Calculations and Actions
The third skill is working with higher-order calculations and actions.
A calculation or action is higher-order when it can be treated like any other value. It can be:
- Passed to a function as an argument
- Returned from a function
- Stored in a variable
- Combined with other behavior
This makes behavior manipulable. Instead of writing every program operation as a one-off sequence, a programmer can create general tools that accept behavior as input or produce new behavior as output.
Passing behavior as a value
Suppose a function receives another function as an argument. The receiving function can then apply the supplied behavior to many values or use it as part of a larger process.
This is different from writing a separate version of the receiving function for every possible behavior. The general function provides the structure, while the passed-in function provides the specific behavior.
A simple conceptual example is a transformation operation that receives:
- A collection of values
- A calculation describing how each value should be transformed
The transformation operation can apply that calculation to every item without needing to know the details of the calculation in advance.
Higher-order functions
Common examples include map, filter, and reduce.
- Map applies a calculation to each element and produces a transformed collection.
- Filter keeps elements that satisfy a specified condition.
- Reduce combines multiple elements into a single result according to a specified combining process.
Together, these operations can form data-transformation pipelines. Each stage performs one general kind of work, while the supplied functions determine the details.
For example, a pipeline might:
- Select employees who meet a condition.
- Transform their salary values.
- Combine the results into a total.
The pipeline is expressed through reusable operations rather than through a single large block of specialized code.
Creating new behavior from existing behavior
Higher-order programming can also create a new calculation or action from an existing one.
For instance, a higher-order operation could take an action and produce a version that automatically retries the action three times if it fails. Without higher-order behavior, each action would need its own separately written retry logic. With a higher-order operation, the retry policy can be defined once and applied consistently.
Similarly, an action could be transformed so that it becomes idempotent. An idempotent operation can be performed more than once without producing an unintended cumulative effect. The important functional-programming idea is that behavior such as retrying or controlling repeated execution can be added systematically rather than rewritten as custom boilerplate each time.
Higher-order actions
Higher-order programming applies not only to pure calculations but also to actions. A sequence of actions can be treated as a value and manipulated according to general rules.
For example, a system may define:
- How a sequence of actions is executed
- What happens when one action fails
- Whether failed actions are retried
- How actions are composed
- How results or failures move through the sequence
This makes behavior more compositional. Instead of writing one large top-down procedure, the program can assemble smaller behaviors using reusable mechanisms.
A mathematical example
A classic example of higher-order calculation is a function that accepts a mathematical function F and returns a new function representing the derivative of F.
The original function might be unknown to the derivative-producing function. It could be any mathematical function that satisfies the required conditions. Conceptually, the higher-order function has the form:
D(F)=F′Here, D receives a function and returns another function. The result is not a single number; it is new behavior that can later be applied to an input.
This demonstrates the expressive power of treating functions as first-class values. A program can manipulate general behavior without knowing every detail of the behavior ahead of time.
Higher-order programming allows a program to operate on behavior itself, making common policies and transformations reusable across many different calculations and actions.
Think About It
A retry mechanism can be written separately for every network operation, or it can be created as a higher-order operation that accepts any action. Which approach is more reusable, and why?
Skill Four: Data Modeling
Once a programmer can distinguish data from behavior, preserve data through immutable values, and manipulate behavior with higher-order operations, the next skill is data modeling.
Data modeling is the process of deciding how facts, measurements, and observations about the world should be represented in a program.
Software often replaces or automates a real-world process. To do that, it must represent relevant facts in concrete structures. For example, a business system may need to represent employees, salaries, vacation amounts, transactions, or events.
The challenge is not simply storing information. The structure must make the information useful for the operations the software needs to perform.
Modeling data for external use
Some data is public-facing. It leaves a library or server and becomes part of an API. This data has a communication role: another developer or program must be able to understand and use it.
External data therefore needs to be:
- Understandable to the receiving developer
- Organized in a predictable way
- Suitable for being read or generated by programs
- Stable enough to serve as part of an interface
Because external data crosses a boundary, its design is constrained by the needs of other systems and developers. Clarity is especially important because the structure itself communicates meaning.
Modeling data for internal use
Internal data modeling has different goals. Internal structures are designed for the needs of the program that uses them.
For example, a program searching through a large space may need a particular representation so that:
- The search is efficient
- All required information is available
- The program can move through possibilities effectively
- The structure supports the necessary calculations
An internal representation does not necessarily need to be convenient for external users. It needs to support the program’s internal work.
Different purposes, different designs
External and internal data models should not automatically be identical. A structure that is easy for a program to search may be difficult for a human or external developer to understand. Conversely, a public format designed for readability may not be the most efficient representation for internal computation.
Good data modeling therefore begins by asking what the data is for:
- Is it crossing a system boundary?
- Is another developer expected to read it?
- Is it optimized for a search or calculation?
- Does it need to remain stable as an interface?
- Does it need to contain information in a form that internal operations can use efficiently?
Data modeling is considered a more advanced functional-programming skill because it requires combining earlier skills. The programmer must understand what should be represented as data, how that data changes immutably, and what calculations or actions will operate on it.
Think About It
Why might a public API use a clear, human-readable data structure while an internal search algorithm uses a different structure for efficiency?
Skill Five: Functional Architecture
The fifth skill is applying functional ideas to the architecture of an entire software system.
A small program may fit in one file without much structural planning. As a system grows, however, placing all code together can make it difficult to understand, modify, and maintain. Architecture provides principles for organizing the system so that change remains manageable.
Functional architecture emphasizes the separation of actions, calculations, and data at a larger scale. Two important patterns are reactive architecture and Onion Architecture.
Reactive Architecture
A reactive architecture organizes a system around changes and events.
The general cycle is:
- Events are generated.
- The system consumes those events.
- The events cause centralized state to be modified.
- The updated state produces a new view of the world.
- That view is projected outward, such as onto a graphical user interface.
- Further user activity generates more events.
This produces a repeating cycle:
events→state changes→view→new eventsThe interface is therefore treated as a projection of the current state. Rather than independently changing many parts of the interface, the system updates state and derives the view from that state.
This design appears in systems such as Redux, the Elm Architecture, and re-frame. The central functional idea is that reactions to data changes drive the system. The architecture makes the flow of information explicit and gives the system a consistent way to respond to events.
Onion Architecture
Onion Architecture organizes a system into three main layers arranged from outside to inside.
The interaction layer
The outer layer is the interaction layer. It communicates with the outside world and contains the actions needed to interact with external systems.
This may include code that:
- Receives messages
- Talks to an API
- Reads external input
- Writes external output
- Coordinates interactions with the environment
Because this layer deals with external systems, it is often the most changeable. An external API may change its format or version, requiring the interaction code to be modified.
The business-rule layer
The second layer is the business-rule layer. This layer contains calculations that express changing business requirements.
Examples include:
- Calculating payroll
- Applying a vacation policy
- Determining how a business process should work
- Applying rules that may change as organizational policies change
The business-rule layer is primarily made of calculations rather than actions. It uses the stable domain concepts inside it while applying rules that may evolve over time.
The domain layer
The innermost layer is the domain layer, which contains the domain model. This layer represents concepts that are relatively timeless within the problem domain.
For example, a business may change its vacation policy, but the domain model can still represent the idea that employees receive vacation. The specific amount of vacation belongs to the business rules, while the general concept of employee vacation belongs to the domain model.
Similarly, the business rules may calculate a particular employee’s salary, while the domain model represents the more stable idea that an employee has a salary represented by some amount.
The layers can be divided further if needed, but the central pattern consists of these three levels:
- Interaction layer: actions involving the outside world
- Business-rule layer: calculations expressing changing policies
- Domain layer: stable concepts in the problem domain
Why the layers are separated
The layers change at different rates:
- The interaction layer may change rapidly because external interfaces and APIs change frequently.
- The business-rule layer may change when organizational policies change.
- The domain layer changes least often because it represents more enduring concepts.
Separating the layers prevents fast-changing details from being mixed with stable concepts. When an API changes, the system should not require the timeless domain model to be rewritten. When a vacation policy changes, the interaction layer should not need to change merely because the calculation changed.
This separation also makes it easier to recognize unusual values. If a business temporarily gives employees zero vacation, the domain model can still represent vacation as an amount. The current policy determines that the amount is zero. A strange or temporary business rule does not necessarily require changing the underlying model.
Functional architecture manages change by placing actions at the boundaries, changing business calculations in a separate layer, and stable domain concepts at the center.
Think About It
If an external API changes its message format, which Onion Architecture layer should change first? Why should the domain layer usually remain unaffected?
How the Five Skills Fit Together
The five skills form a progression.
First, a programmer distinguishes actions, calculations, and data. This reveals which code is predictable and which code requires careful control.
Second, the programmer works with immutable values so that data does not change unexpectedly. Changes become explicit creation of new values.
Third, the programmer treats calculations and actions as values. Higher-order operations can then transform behavior, add policies such as retries, and create reusable data pipelines.
Fourth, the programmer models data so that it supports its intended purpose, whether that purpose is communication across an API boundary or efficient internal computation.
Finally, the programmer applies these ideas architecturally. Actions can be placed at system boundaries, calculations can express business rules, data can represent state, and stable domain concepts can be separated from rapidly changing details.
Comprehensive Review
Functional programming can be understood most practically as a set of skills rather than as a single rigid definition.
The five central skills are:
-
Discriminating actions, calculations, and data
Calculations produce stable results from inputs, data represents information, and actions depend on timing or interaction with the world. -
Working with immutable values
Existing values are preserved, and changes are represented by creating new versions. This is especially important when updating nested structures. -
Using and creating higher-order calculations and actions
Functions and other behaviors can be passed, stored, returned, transformed, and composed. This enables tools such as map, filter, reduce, retries, and other reusable policies. -
Modeling data
Facts about the world must be structured so that they can be used effectively. External data emphasizes clarity and communication, while internal data may emphasize efficient computation or search. -
Using functional architecture
Larger systems can organize behavior around data changes and events, or separate interaction actions, business-rule calculations, and stable domain concepts through patterns such as reactive architecture and Onion Architecture.
Together, these skills make software easier to reason about. Predictable calculations and preserved data form a stable core, while actions and changing external details are kept under deliberate control. Higher-order operations make behavior reusable, data modeling makes information useful, and architecture keeps the entire system manageable as it grows.

Ask anything
We've read this whole study set, so questions about it get the best answers.