IOOption<R> class final

IOOption<R> represents an synchronous computation that may fails yielding a None or returns a Some(R) when successful.

If you want to represent an synchronous computation that never fails, see IO.

If you want to represent an synchronous computation that returns an object when it fails, see IOEither.

Inheritance
Mixed in types

Constructors

IOOption(Option<R> _run())
Build a IOOption from a function returning a Option<R>.
const
IOOption.Do(DoFunctionIOOption<R> f)
Initialize a Do Notation chain.
factory
IOOption.flatten(IOOption<IOOption<R>> ioOption)
Flat a IOOption contained inside another IOOption to be a single IOOption.
factory
IOOption.fromNullable(R? r)
If r is null, then return None. Otherwise return Right(r).
factory
IOOption.fromPredicate(R value, bool predicate(R a))
When calling predicate with value returns true, then running IOOption returns Some(value). Otherwise return None.
factory
IOOption.none()
Build a IOOption that returns a None.
factory
IOOption.of(R r)
Build a IOOption that returns a Some(r).
factory
IOOption.some(R r)
Build a IOOption that returns a Some(r).
factory
IOOption.tryCatch(R run())
Converts a function that may throw to a function that never throws but returns a Option instead.
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

alt(covariant IOOption<R> orElse()) IOOption<R>
When this IOOption returns Some, then return the current IOOption. Otherwise return the result of orElse.
override
andThen<C>(covariant IOOption<C> then()) IOOption<C>
If running this IOOption returns Some, then return the result of calling then. Otherwise return None.
override
ap<C>(covariant IOOption<C Function(R r)> a) IOOption<C>
Apply the function contained inside a to change the value on the Some from type R to a value of type C.
override
call<B>(covariant IOOption<B> chain) IOOption<B>
Chain multiple IOOption functions.
override
chainFirst<B>(covariant Monad<_IOOptionHKT, B> chain(R a)) HKT<_IOOptionHKT, R>
inherited
flatMap<C>(covariant IOOption<C> f(R r)) IOOption<C>
Used to chain multiple functions that return a IOOption.
override
getOrElse(R orElse()) IO<R>
Extract the result of this IOOption into a IO.
map<C>(C f(R r)) IOOption<C>
If running this IOOption returns Some, then change its value from type R to type C using function f.
override
map2<C, D>(covariant IOOption<C> m1, D f(R b, C c)) IOOption<D>
Change the return type of this IOOption based on its value of type R and the value of type C of another IOOption.
override
map3<C, D, E>(covariant IOOption<C> m1, covariant IOOption<D> m2, E f(R b, C c, D d)) IOOption<E>
Change the return type of this IOOption based on its value of type R, the value of type C of a second IOOption, and the value of type D of a third IOOption.
override
match<A>(A onNone(), A onSome(R r)) IO<A>
Pattern matching to convert a IOOption to a IO.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse<TL>(IOOption<R> orElse()) IOOption<R>
When this IOOption returns a None then return the result of orElse. Otherwise return this IOOption.
pure<C>(C c) IOOption<C>
Returns a IOOption that returns Some(c).
override
run() Option<R>
Run the IO and return a Option<R>.
toIOEither<L>(L onNone()) IOEither<L, R>
Convert this IOOption to IOEither.
toString() String
A string representation of this object.
inherited
toTaskEither<L>(L onNone()) TaskEither<L, R>
Convert this IOOption to TaskEither.
toTaskOption<L>() TaskOption<R>
Convert this IOOption to TaskOption.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromEither<L, R>(Either<L, R> either) IOOption<R>
Build a IOOption from either that returns None when either is Left, otherwise it returns Some.
sequenceList<A>(List<IOOption<A>> list) IOOption<List<A>>
Convert a List<IOOption<A>> to a single IOOption<List<A>>.
traverseList<A, B>(List<A> list, IOOption<B> f(A a)) IOOption<List<B>>
Map each element in the list to a IOOption using the function f, and collect the result in an IOOption<List<B>>.
traverseListWithIndex<A, B>(List<A> list, IOOption<B> f(A a, int i)) IOOption<List<B>>
Map each element in the list to a IOOption using the function f, and collect the result in an IOOption<List<B>>.
tryCatchK<R, A>(R run(A a)) IOOption<R> Function(A a)
Converts a function that may throw to a function that never throws but returns a Option instead.