Skip to content

Add an example of asynchronous composition with libfn #393

Description

@Bronek

README used to claim that libfn is a natural fit for asynchronous composition, naming coroutines and senders/receivers. That claim was removed during the 0.1 documentation pass because nothing in the repository backed it — no example, no reference page. The property underneath it is real, though, and worth demonstrating rather than asserting.

What is true and demonstrable today:

  • an operation is a value: fn::and_then(f) is a description of a step, not its execution, and it runs when a monad is piped into it;
  • such a step is constexpr, copyable, and can be stored, passed around and applied later — including in a constant expression;
  • so a framework can hold the steps of a computation and apply them as results arrive, with a typed error channel and no hidden control flow.

An example that shows this would earn the claim back, and README could then state it with a pointer.

Scope. Any asynchronous model will do. Coroutines and senders/receivers are not required — plain Boost.Asio would demonstrate the point perfectly well. One example is enough to start.

The design question to settle first. Every example under examples/ is currently free of third-party dependencies, is built in C++20, C++23 and C++26 modes, and is registered as a ctest target that runs across the full CI matrix — Linux gcc/clang, macOS, MSVC, plus the nix, bazel, vcpkg and conan package-test lanes. An example needing Boost would be the first external dependency in that set, so it should be gated on the dependency being found rather than added unconditionally; otherwise every lane and every packaging route acquires a Boost requirement it does not have today.

Assisted-by: Claude:claude-opus-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationrelease-0.2Planned for release 0.2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions