To model computation and manage control flow success failure alternatives and empty states uses computation carriers often called monadic types The library defines exactly four carrier families divided by their fallibility and payload capacity The fallible carriers representing A carrier that either holds a successful value of type or is empty representing A carrier that either holds a successful value of type or an error of type is infallible when its error side is Note and are the extensions of the standards conforming polyfills C mechanics that preserve the algebra covers the two layers The infallible identity carriers Always contains a single successful value of type Always contains one of several selected alternatives representing the complete state space of the computation Because implies that an alternative is always present is incomplete an always present selected alternative requires at least one alternative to exist Additionally the infallible state representing can never fail because represents the initial zero object 0 the uninhabited type Lacking any possible error alternatives it acts as an infallible graded unit context Since it is a specialized state of rather than a unique template it is classified under the same computation carrier Together and form the identity cluster NOTE Note just<copack<Ts >> is spelled choice<Ts > To carry several alternatives that cannot fail use a computation that always succeeds with a result that is one of Spelling the same shape as does not compile rejects a payload with so the shape has one canonical spelling exactly as has one canonical form for its alternatives These carriers constrain their payloads While is supported as a standard conforming exception other carriers reject raw reference types outright references must be wrapped inside a detailed in The sum and product payloads pack and copack Carriers have control flow raw data does not Raw algebraic constructssuch as product sum or s own and are passive data layouts They contain no intrinsic control flow no concept of short circuiting and no built in notion of success versus failure Composing computations requires wrapping these values in computation carriers Product composition conjunction and sum composition disjunction operate on carriers not raw data The carrier manages success propagation and short circuits failures Carrier Bridging Interoperable Pipelines Because these carriers represent different computational contexts pipelines often need to transition between them licenses explicit cross carrier bridging via pipeline scoped operations using Standard fallible carriers can bridge to each other on their error empty recovery paths via pipeline functor e g to or vice versa This is safe because on the success path the successful value is preserved and bypasses the recovery callback The transition only occurs on the handled failure branch allowing you to gracefully convert a missing value into a concrete error or decay a detailed error into an empty state Member functions and see Sections 8 and 10 do not support cross carrier bridging to avoid coupling between different carriers Pipeline functors lying a layer above carriers can perform these transitions without coupling Identity carriers bridge in the other direction on the success path The identity cluster covers that together with the identity cluster libfn optional<T> T std nullopt expected<T E> T E expected copack<> optional expected fn pfn just<T> T choice<Ts > choice choice<> expected<T copack<>> copack<> expected just choice expected<T copack<>> choice<Ts > Ts just<copack<Ts >> just copack a just over a copack is spelled choice copack optional<T&> pack std tuple std variant libfn pack copack libfn operator| fn or_else expected optional auto test_failure_bridge fn expected<int IoError> ex fn optional<int> opt > void Fallible carriers can bridge to each other on the failure empty recovery path auto expected_to_optional ex | fn or_else IoError return fn optional<int> static_assert std same_as<decltype expected_to_optional fn optional<int>> auto optional_to_expected opt | fn or_else return fn expected<int IoError> 100 static_assert std same_as<decltype optional_to_expected fn expected<int IoError>> or_else and_then