some 2.2.0 copy "some: ^2.2.0" to clipboard
some: ^2.2.0 copied to clipboard

Some / Maybe / Option / Result / Nullable, like Haskel Maybe, Can avoid semantic confusion caused by returning null when returning a value

example/example.md

Import #

import 'package:some/index.dart'; // import all

Create #

Maybe<int> some = Some(1);
Maybe<int> none = None();

Check has value #

some.isSome
none.isNone
some.has

Get value #

if(some.has) {
    some.val!
}

Monadic #

some.map((v) => 'some');
some.then((v) => 'some');
some.flatMap((v) => Some('some'));
some.andThen((v) => Some('some'));

Logical #

some.and(Some('some'));
some.andThen((v) => Some('some'));
some.or(Some('some'));
some.orElse(() => Some('some'));
some.xor(Some('some'));

Flatten #

someSome.flatten();

Pattern matching #

some.when(some: (v) => 'some', none: () => 'none');
some.some((v) => 'some');
none.none(() => 'none');
none.defaultVal('none');
none.defaultValFn(() => 'none');
3
likes
130
pub points
42%
popularity

Publisher

unverified uploader

Some / Maybe / Option / Result / Nullable, like Haskel Maybe, Can avoid semantic confusion caused by returning null when returning a value

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on some