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

outdated

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

Some / Maybe / Option / Result / Nullable #

Can avoid semantic confusion caused by returning null when returning a value

like Haskel Maybe


pub


Usage #

Import #

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

import 'package:some/maybe.dart'; // only class Maybe
import 'package:some/some.dart'; // only class Some
import 'package:some/none.dart'; // only class None

import 'package:some/null.dart'; // only no null function

Create #

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

GetValue #

if(some.has) {
    some.val
}

Pattern matching #

if(some is Some) {}
if(some is Some<int>) {}
if(some is None) {}
some.when(some: (v) => 'some', none: () => 'none');
some.some((v) => 'some');
none.none(() => 'none');
none.defaultVal('none');
none.defaultValFn(() => 'none');
3
likes
0
pub points
54%
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

License

unknown (license)

More

Packages that depend on some