maybe_just_nothing 0.5.3 copy "maybe_just_nothing: ^0.5.3" to clipboard
maybe_just_nothing: ^0.5.3 copied to clipboard

Yet another variation of the good old Maybe monad with eager execution written in Dart.

example/example.dart

import 'package:maybe_just_nothing/maybe_just_nothing.dart';

Maybe<int> addTwoIntegers(dynamic a, dynamic b) =>
    Just(a).type<int>().merge(Just(b).type<int>(), (int a, int b) => a + b);

void main() {
  // Prints 42
  addTwoIntegers(40, 2).ifPresent(print);

  // Does nothing since one of the values is null.
  addTwoIntegers(40, null).ifPresent(print);

  // Does nothing since one of the values is not an integer.
  addTwoIntegers('Oops', 2).ifPresent(print);
}
9
likes
150
points
164k
downloads

Publisher

verified publisherkarapetov.com

Weekly Downloads

Yet another variation of the good old Maybe monad with eager execution written in Dart.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on maybe_just_nothing