fp library

Stable functional primitives for Dust runtimes and generated code.

Import this library when app code wants Dust-owned Option, Result, or Unit types without taking a dependency on an external functional package. These are Dust's own types rather than a re-export of fpdart or dartz. Generated code returns them, so they cannot be optional, and a runtime that pulled in a functional package would put that package in the dependency graph of every project that runs dust build. Owning three small types costs less than that.

The contract is stable within a major version, and Option is still growing: see the tracking issue for the methods it does not have yet.

import 'package:dust_dart/fp.dart';

final nickname = Some<String?>('John');
final saved = Ok<Unit, String>(unit);

Classes

Err<T, E>
Failed operation result.
None<T>
Option state for an absent value.
Ok<T, E>
Successful operation result.
Option<T>
Optional value wrapper for Rust-style present-or-absent values.
Result<T, E>
Result of an operation that can either succeed with T or fail with E.
Some<T>
Option state for a present value.
Unit
Empty success value for operations that only signal completion.

Extensions

OptionCombine on Option<T>
Combining Option values, and moving between Option and Result.
OptionFlatten on Option<Option<T>>
Removing one level of Option nesting.
OptionQuery on Option<T>
Reading an Option without matching on it.
OptionTransform on Option<T>
Transforming and choosing between Option values.
OptionTranspose on Option<Result<T, E>>
Swapping an Option of a Result inside out.
OptionUnzip on Option<(A, B)>
Splitting an Option of a pair.

Constants

unit → const Unit
Shared unit value.