liveBook · Manning

Lifting

As explained in Data-Oriented Programming in Java

Lifting is a functional programming technique that adapts a function on ordinary values to operate within a wrapper or computational context.

Lifting adapts an ordinary function so it operates on values inside a computational context such as Optional. Instead of manually unpacking, checking, and rebuilding Optional values, lift moves the function into that context while preserving its original logic. section 7.12 section 7.8.2

A binary lifter follows a small sequence of generalizations:

  • Start with an operation that handles two present Optional values and returns Optional.empty() when either value is absent. section 7.8.2
  • Pass the BinaryOperator into that pattern, then generalize the value type. section 7.8.2
  • Separate the operator from its arguments so lift returns a BinaryOperator<Optional<A>>. section 7.8.2

Lifting familiar operations

lift(Integer::sum) produces a BinaryOperator<Optional<Integer>>, while lift(String::concat) produces a BinaryOperator<Optional<String>>. Applying the first to Optional.of(1) and Optional.of(2) yields Optional.of(3); applying the second with an empty operand yields Optional.empty().

How Data-Oriented Programming in Java covers it

How deep it goes
Derives generic binary lifters and shows explicit and flatMap/map implementations, focusing on Optional rather than broader computational contexts.
Examples
Demonstrates lifted integer addition and string concatenation with present and absent Optional operands.
What it assumes
Assumes Java functions, BinaryOperator, generics, lambdas, and Optional, while deriving the lifting abstraction incrementally.
What you can do after
Apply it via generic lifters that reuse ordinary functions while automatically propagating Optional absence.
How it connects
Connects lifting with Optional, BinaryOperator, generics, map, flatMap, and algebraic thinking.

Also explained in

Compare how 3 books explain lifting →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.