some 1.3.0

Dart native js
Flutter Android iOS web

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 MIT


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');
0
likes
100
pub points
54%
popularity

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

Uploader

alvizels@gmail.com

License

MIT (LICENSE)

More

Packages that depend on some