- OptionUnsafe <A>
- None = default
- Some (A value)
- OptionUnsafe (IEnumerable<A> option)
- GetObjectData (SerializationInfo info, StreamingContext context)
- Case
- GetEnumerator ()
- Equals (OptionUnsafe<A> other)
- Equals <EqA> (OptionUnsafe<A> other)
- CompareTo (OptionUnsafe<A> other)
- CompareTo <OrdA> (OptionUnsafe<A> other)
- < (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- <= (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- > (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- >= (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- == (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- != (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- | (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs)
- true (OptionUnsafe<A> value)
- false (OptionUnsafe<A> value)
- Equals (object obj)
- GetHashCode ()
- CompareTo (object obj)
- ToString ()
- IsSome
- IsNone
- Do (Action<A> f)
- Select <B> (Func<A, B> f)
- Map <B> (Func<A, B> f)
- Bind <B> (Func<A, OptionUnsafe<B>> f)
- BiBind <B> (Func<A, OptionUnsafe<B>> Some, Func<OptionUnsafe<B>> None)
- SelectMany <B, C> ( Func<A, OptionUnsafe<B>> bind, Func<A, B, C> project)
- MatchUntyped <R> (Func<object, R> Some, Func<R> None)
- MatchUntypedUnsafe <R> (Func<object, R> Some, Func<R> None)
- GetUnderlyingType ()
- ToArray ()
- ToList ()
- ToSeq ()
- AsEnumerable ()
- ToEff ()
- ToEff (Error Fail)
- ToAff ()
- ToAff (Error Fail)
- ToValidation <FAIL> (FAIL defaultFailureValue)
- ToEither <L> (L defaultLeftValue)
- ToEither <L> (Func<L> Left)
- Some (Action<A> f)
- Some <B> (Func<A, B> f)
- MatchUnsafe <B> (Func<A, B> Some, Func<B> None)
- MatchUnsafe <B> (Func<A, B> Some, B None)
- MatchUnsafe (Action<A> Some, Action None)
- IfSomeUnsafe (Action<A> f)
- IfSomeUnsafe (Func<A, Unit> f)
- IfNoneUnsafe (Func<A> None)
- IfNoneUnsafe (A noneValue)
- Fold <S> (S state, Func<S, A, S> folder)
- FoldBack <S> (S state, Func<S, A, S> folder)
- BiFold <S> (S state, Func<S, A, S> Some, Func<S, Unit, S> None)
- BiFold <S> (S state, Func<S, A, S> Some, Func<S, S> None)
- BiMap <B> (Func<A, B> Some, Func<Unit, B> None)
- BiMap <B> (Func<A, B> Some, Func<B> None)
- Count ()
- ForAll (Func<A, bool> pred)
- BiForAll (Func<A, bool> Some, Func<Unit, bool> None)
- BiForAll (Func<A, bool> Some, Func<bool> None)
- Exists (Func<A, bool> pred)
- BiExists (Func<A, bool> Some, Func<Unit, bool> None)
- BiExists (Func<A, bool> Some, Func<bool> None)
- Iter (Action<A> Some)
- BiIter (Action<A> Some, Action<Unit> None)
- BiIter (Action<A> Some, Action None)
- Filter (Func<A, bool> pred)
- Where (Func<A, bool> pred)
- Join <B, C, D> ( OptionUnsafe<B> inner, Func<A, C> outerKeyMap, Func<B, C> innerKeyMap, Func<A, B, D> project)
- ParMap <B, C> (Func<A, B, C> func)
- ParMap <B, C, D> (Func<A, B, C, D> func)
- MapAsync <B> (Func<A, Task<B>> map)
- OptionUnsafeExtensions
- Flatten <A> (this OptionUnsafe<OptionUnsafe<A>> ma)
- Somes <A> (this IEnumerable<OptionUnsafe<A>> self)
- Somes <A> (this Seq<OptionUnsafe<A>> self)
- Add <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y)
- Subtract <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y)
- Product <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y)
- Divide <NUM, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y)
- Apply <A, B> (this OptionUnsafe<Func<A, B>> fab, OptionUnsafe<A> fa)
- Apply <A, B> (this Func<A, B> fab, OptionUnsafe<A> fa)
- Apply <A, B, C> (this OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- Apply <A, B, C> (this Func<A, B, C> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- Apply <A, B, C> (this OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa)
- Apply <A, B, C> (this Func<A, B, C> fabc, OptionUnsafe<A> fa)
- Apply <A, B, C> (this OptionUnsafe<Func<A, Func<B, C>>> fabc, OptionUnsafe<A> fa)
- Apply <A, B, C> (this Func<A, Func<B, C>> fabc, OptionUnsafe<A> fa)
- Action <A, B> (this OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- ToNullable <A> (this OptionUnsafe<A> ma)
- Match <T, R> (this IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None )
- Match <T, R> (this IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None)
- MatchAsync <A, B> (this OptionUnsafe<A> ma, Func<A, Task<B>> Some, Func<B> None)
- MatchAsync <A, B> (this OptionUnsafe<A> ma, Func<A, Task<B>> Some, Func<Task<B>> None)
- Sum (this OptionUnsafe<int> a)
- Sum <NUM, A> (this OptionUnsafe<A> self)
- MapAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, Task<B>> map)
- MapAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, B> map)
- MapAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, B> map)
- MapAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, Task<B>> map)
- BindAsync <A, B> (this OptionUnsafe<A> self, Func<A, Task<OptionUnsafe<B>>> bind)
- BindAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, Task<OptionUnsafe<B>>> bind)
- BindAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, OptionUnsafe<B>> bind)
- BindAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, OptionUnsafe<B>> bind)
- BindAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, Task<OptionUnsafe<B>>> bind)
- IterAsync <A> (this Task<OptionUnsafe<A>> self, Action<A> Some)
- IterAsync <A> (this OptionUnsafe<Task<A>> self, Action<A> Some)
- CountAsync <A> (this Task<OptionUnsafe<A>> self)
- FoldAsync <A, S> (this Task<OptionUnsafe<A>> self, S state, Func<S, A, S> folder)
- FoldAsync <A, S> (this OptionUnsafe<Task<A>> self, S state, Func<S, A, S> folder)
- ForAllAsync <A> (this Task<OptionUnsafe<A>> self, Func<A, bool> pred)
- ForAllAsync <A> (this OptionUnsafe<Task<A>> self, Func<A, bool> pred)
- ExistsAsync <A> (this Task<OptionUnsafe<A>> self, Func<A, bool> pred)
- ExistsAsync <A> (this OptionUnsafe<Task<A>> self, Func<A, bool> pred)
- Prelude
- flatten <A> (OptionUnsafe<OptionUnsafe<A>> ma)
- subtract <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs)
- product <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs)
- divide <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs)
- add <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs)
- isSome <T> (OptionUnsafe<T> value)
- isNone <T> (OptionUnsafe<T> value)
- SomeUnsafe <T> (T value)
- SomeUnsafe <T> (Func<Unit, T> f)
- ifSomeUnsafe <T> (OptionUnsafe<T> option, Action<T> Some)
- ifNoneUnsafe <T> (OptionUnsafe<T> option, Func<T> None)
- ifNoneUnsafe <T> (OptionUnsafe<T> option, T noneValue)
- matchUnsafe <T, R> (OptionUnsafe<T> option, Func<T, R> Some, Func<R> None)
- matchUnsafe <T> (OptionUnsafe<T> option, Action<T> Some, Action None)
- apply <A, B> (OptionUnsafe<Func<A, B>> fab, OptionUnsafe<A> fa)
- apply <A, B> (Func<A, B> fab, OptionUnsafe<A> fa)
- apply <A, B, C> (OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- apply <A, B, C> (Func<A, B, C> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- apply <A, B, C> (OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa)
- apply <A, B, C> (Func<A, B, C> fabc, OptionUnsafe<A> fa)
- apply <A, B, C> (OptionUnsafe<Func<A, Func<B, C>>> fabc, OptionUnsafe<A> fa)
- apply <A, B, C> (Func<A, Func<B, C>> fabc, OptionUnsafe<A> fa)
- action <A, B> (OptionUnsafe<A> fa, OptionUnsafe<B> fb)
- fold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> folder)
- bifold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> Some, Func<S, S> None)
- bifold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> Some, Func<S, Unit, S> None)
- forall <A> (OptionUnsafe<A> option, Func<A, bool> pred)
- biforall <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<Unit, bool> None)
- biforall <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<bool> None)
- count <A> (OptionUnsafe<A> option)
- exists <A> (OptionUnsafe<A> option, Func<A, bool> pred)
- biexists <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<Unit, bool> None)
- biexists <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<bool> None)
- map <A, B> (OptionUnsafe<A> option, Func<A, B> f)
- bimap <A, B> (OptionUnsafe<A> option, Func<A, B> Some, Func<B> None)
- bimap <A, B> (OptionUnsafe<A> option, Func<A, B> Some, Func<Unit, B> None)
- parmap <T1, T2, R> (OptionUnsafe<T1> option, Func<T1, T2, R> mapper)
- parmap <T1, T2, T3, R> (OptionUnsafe<T1> option, Func<T1, T2, T3, R> mapper)
- filter <T> (OptionUnsafe<T> option, Func<T, bool> pred)
- bind <T, R> (OptionUnsafe<T> option, Func<T, OptionUnsafe<R>> binder)
- matchUnsafe <T, R> (IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None )
- matchUnsafe <T, R> (IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None )
- somes <T> (IEnumerable<OptionUnsafe<T>> list)
- toList <T> (OptionUnsafe<T> option)
- toArray <T> (OptionUnsafe<T> option)
struct OptionUnsafe <A> Source #
Discriminated union type. Can be in one of two states:
Some(a)
None
Typeclass instances available for this type:
BiFoldable : MOptionUnsafe
Eq : EqOpt
Foldable : MOptionUnsafe
Functor : FOptionUnsafe
MonadPlus : MOptionUnsafe
Optional : MOptionUnsafe
Ord : OrdOpt
type | A | Bound value |
field OptionUnsafe<A> None = default Source #
None
Reference version of option for use in pattern-matching
Some = result is A
None = result is null
constructor OptionUnsafe (IEnumerable<A> option) Source #
Ctor that facilitates serialisation
param | option | None or Some A. |
method OptionUnsafe<A> Some (A value) Source #
Construct an OptionUnsafe of A in a Some state
param | value | Value to bind, must be non-null |
returns | OptionUnsafe of A |
method void GetObjectData (SerializationInfo info, StreamingContext context) Source #
method IEnumerator<A> GetEnumerator () Source #
method bool Equals (OptionUnsafe<A> other) Source #
Uses the EqDefault
instance to do an equality check on the bound value.
To use anything other than the default call oa.Equals<EqA>(ob)
where EqA
is an instance derived from Eq<A>
This uses the EqDefault
instance for comparison of the bound A
values.
The EqDefault
instance wraps up the .NET EqualityComparer.Default
behaviour.
param | other | The |
returns |
|
method bool Equals <EqA> (OptionUnsafe<A> other) Source #
Uses the EqA
instance to do an equality check on the bound value.
param | other | The |
returns |
|
method int CompareTo (OptionUnsafe<A> other) Source #
Uses the OrdDefault
instance to do an ordering comparison on the bound
value. To use anything other than the default call this.Compare<OrdA>(this, other)
,
where OrdA
is an instance derived from Ord<A>
param | other | The |
method int CompareTo <OrdA> (OptionUnsafe<A> other) Source #
Uses the Ord
instance provided to do an ordering comparison on the bound
value.
param | other | The |
method bool Equals (object obj) Source #
DO NOT USE - Use the Structural equality variant of this method Equals<EQ, A>(y)
method int GetHashCode () Source #
Calculate the hash-code from the bound value, unless the OptionUnsafe is in a None state, in which case the hash-code will be 0
returns | Hash-code from the bound value, unless the OptionUnsafe is in a None state, in which case the hash-code will be 0 |
method string ToString () Source #
Get a string representation of the OptionUnsafe
returns | String representation of the OptionUnsafe |
method OptionUnsafe<A> Do (Action<A> f) Source #
Impure iteration of the bound value in the structure
returns | Returns the original unmodified structure |
method OptionUnsafe<B> Select <B> (Func<A, B> f) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | f | Projection function |
returns | Mapped functor |
method OptionUnsafe<B> Map <B> (Func<A, B> f) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | f | Projection function |
returns | Mapped functor |
method OptionUnsafe<B> BiBind <B> (Func<A, OptionUnsafe<B>> Some, Func<OptionUnsafe<B>> None) Source #
Bi-bind. Allows mapping of both monad states
method OptionUnsafe<C> SelectMany <B, C> ( Func<A, OptionUnsafe<B>> bind, Func<A, B, C> project) Source #
Monad bind operation
method R MatchUntyped <R> (Func<object, R> Some, Func<R> None) Source #
Match operation with an untyped value for Some. This can be useful for serialisation and dealing with the IOptional interface
type | R | The return type |
param | Some | Operation to perform if the option is in a Some state |
param | None | Operation to perform if the option is in a None state |
returns | The result of the match operation |
method R MatchUntypedUnsafe <R> (Func<object, R> Some, Func<R> None) Source #
Match operation with an untyped value for Some. This can be useful for serialisation and dealing with the IOptional interface
type | R | The return type |
param | Some | Operation to perform if the option is in a Some state |
param | None | Operation to perform if the option is in a None state |
returns | The result of the match operation |
method Type GetUnderlyingType () Source #
Get the Type of the bound value
returns | Type of the bound value |
method Arr<A> ToArray () Source #
Convert the OptionUnsafe to an enumerable of zero or one items
returns | An enumerable of zero or one items |
method Lst<A> ToList () Source #
Convert the OptionUnsafe to an immutable list of zero or one items
returns | An immutable list of zero or one items |
method Seq<A> ToSeq () Source #
Convert the OptionUnsafe to an enumerable sequence of zero or one items
returns | An enumerable sequence of zero or one items |
method IEnumerable<A> AsEnumerable () Source #
Convert the OptionUnsafe to an enumerable of zero or one items
returns | An enumerable of zero or one items |
method Eff<A> ToEff () Source #
Convert the structure to an Eff
returns | An Eff representation of the structure |
method Eff<A> ToEff (Error Fail) Source #
Convert the structure to an Eff
param | Fail | Default value if the structure is in a None state |
returns | An Eff representation of the structure |
method Aff<A> ToAff () Source #
Convert the structure to an Aff
returns | An Aff representation of the structure |
method Aff<A> ToAff (Error Fail) Source #
Convert the structure to an Aff
param | Fail | Default value if the structure is in a None state |
returns | An Aff representation of the structure |
method Validation<FAIL, A> ToValidation <FAIL> (FAIL defaultFailureValue) Source #
method EitherUnsafe<L, A> ToEither <L> (L defaultLeftValue) Source #
Convert the structure to an EitherUnsafe
param | defaultLeftValue | Default value if the structure is in a None state |
returns | An Either representation of the structure |
method EitherUnsafe<L, A> ToEither <L> (Func<L> Left) Source #
Convert the structure to an EitherUnsafe
param | Left | Function to invoke to get a default value if the structure is in a None state |
returns | An Either representation of the structure |
method SomeUnsafeUnitContext<MOptionUnsafe<A>, OptionUnsafe<A>, A> Some (Action<A> f) Source #
Fluent pattern matching. Provide a Some handler and then follow on fluently with .None(...) to complete the matching operation. This is for dispatching actions, use Some<A,B>(...) to return a value from the match operation.
param | f | The Some(x) match operation |
method SomeUnsafeContext<MOptionUnsafe<A>, OptionUnsafe<A>, A, B> Some <B> (Func<A, B> f) Source #
Fluent pattern matching. Provide a Some handler and then follow on fluently with .None(...) to complete the matching operation. This is for returning a value from the match operation, to dispatch an action instead, use Some(...)
type | B | Match operation return value type |
param | f | The Some(x) match operation |
returns | The result of the match operation |
method B MatchUnsafe <B> (Func<A, B> Some, Func<B> None) Source #
Match the two states of the OptionUnsafe and return a B, which can be null.
type | B | Return type |
param | Some | Some match operation. May return null. |
param | None | None match operation. May return null. |
returns | B, or null |
method B MatchUnsafe <B> (Func<A, B> Some, B None) Source #
Match the two states of the OptionUnsafe and return a B, which can be null.
type | B | Return type |
param | Some | Some match operation. May return null. |
param | None | None match operation. May return null. |
returns | B, or null |
method Unit MatchUnsafe (Action<A> Some, Action None) Source #
Match the two states of the OptionUnsafe
param | Some | Some match operation |
param | None | None match operation |
method Unit IfSomeUnsafe (Action<A> f) Source #
Invokes the action if OptionUnsafe is in the Some state, otherwise nothing happens.
param | f | Action to invoke if OptionUnsafe is in the Some state |
method Unit IfSomeUnsafe (Func<A, Unit> f) Source #
Invokes the f function if OptionUnsafe is in the Some state, otherwise nothing happens.
param | f | Function to invoke if OptionUnsafe is in the Some state |
method A IfNoneUnsafe (Func<A> None) Source #
Returns the result of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned.
Will not accept a null return value from the None operation
param | None | Operation to invoke if the structure is in a None state |
returns | Tesult of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned. |
method A IfNoneUnsafe (A noneValue) Source #
Returns the noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned.
Will not accept a null noneValue
param | noneValue | Value to return if in a None state |
returns | noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned |
method S Fold <S> (S state, Func<S, A, S> folder) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | folder | Folder function, applied if OptionUnsafe is in a Some state |
returns | The aggregate state |
method S FoldBack <S> (S state, Func<S, A, S> folder) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | folder | Folder function, applied if OptionUnsafe is in a Some state |
returns | The aggregate state |
method S BiFold <S> (S state, Func<S, A, S> Some, Func<S, Unit, S> None) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | Some | Folder function, applied if OptionUnsafe is in a Some state |
param | None | Folder function, applied if OptionUnsafe is in a None state |
returns | The aggregate state |
method S BiFold <S> (S state, Func<S, A, S> Some, Func<S, S> None) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | Some | Folder function, applied if OptionUnsafe is in a Some state |
param | None | Folder function, applied if OptionUnsafe is in a None state |
returns | The aggregate state |
method OptionUnsafe<B> BiMap <B> (Func<A, B> Some, Func<Unit, B> None) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | Some | Projection function |
param | None | Projection function |
returns | Mapped functor |
method OptionUnsafe<B> BiMap <B> (Func<A, B> Some, Func<B> None) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | Some | Projection function |
param | None | Projection function |
returns | Mapped functor |
Return the number of bound values in this structure:
None = 0
Some = 1
returns |
method bool ForAll (Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied. |
method bool BiForAll (Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool BiForAll (Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool Exists (Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool BiExists (Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool BiExists (Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method Unit Iter (Action<A> Some) Source #
Invoke an action for the bound value (if in a Some state)
param | Some | Action to invoke |
method Unit BiIter (Action<A> Some, Action<Unit> None) Source #
Invoke an action depending on the state of the OptionUnsafe
param | Some | Action to invoke if in a Some state |
param | None | Action to invoke if in a None state |
method Unit BiIter (Action<A> Some, Action None) Source #
Invoke an action depending on the state of the OptionUnsafe
param | Some | Action to invoke if in a Some state |
param | None | Action to invoke if in a None state |
method OptionUnsafe<A> Filter (Func<A, bool> pred) Source #
Apply a predicate to the bound value (if in a Some state)
param | pred | Predicate to apply |
returns | Some(x) if the OptionUnsafe is in a Some state and the predicate returns True. None otherwise. |
method OptionUnsafe<A> Where (Func<A, bool> pred) Source #
Apply a predicate to the bound value (if in a Some state)
param | pred | Predicate to apply |
returns | Some(x) if the OptionUnsafe is in a Some state and the predicate returns True. None otherwise. |
method OptionUnsafe<D> Join <B, C, D> ( OptionUnsafe<B> inner, Func<A, C> outerKeyMap, Func<B, C> innerKeyMap, Func<A, B, D> project) Source #
Monadic join
operator < (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs < rhs |
operator <= (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs <= rhs |
operator > (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs > rhs |
operator >= (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Comparison operator
param | lhs | The left hand side of the operation |
param | rhs | The right hand side of the operation |
returns | True if lhs >= rhs |
operator == (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Equality operator
This uses the EqDefault instance for comparison of the bound A values. The EqDefault instance wraps up the .NET EqualityComparer.Default behaviour. For more control over equality you can call:
equals<EQ, A>(lhs, rhs);
Where EQ is a struct derived from Eq. For example:
equals<EqString, string>(lhs, rhs);
equals<EqArray<int>, int[]>(lhs, rhs);
param | lhs | Left hand side of the operation |
param | rhs | Right hand side of the operation |
returns | True if the values are equal |
operator != (OptionUnsafe<A> lhs, OptionUnsafe<A> rhs) Source #
Non-equality operator
This uses the EqDefault instance for comparison of the A value. The EqDefault type-class wraps up the .NET EqualityComparer.Default behaviour. For more control over equality you can call:
!equals<EQ, A>(lhs, rhs);
Where EQ is a struct derived from Eq. For example:
!equals<EqString, string>(lhs, rhs);
!equals<EqArray<int>, int[]>(lhs, rhs);
param | lhs | Left hand side of the operation |
param | rhs | Right hand side of the operation |
returns | True if the values are equal |
class OptionUnsafeExtensions Source #
Extension methods for OptionUnsafe
method IEnumerable<A> Somes <A> (this IEnumerable<OptionUnsafe<A>> self) Source #
Extracts from a list of OptionUnsafe
all the Some
elements.
All the Some
elements are extracted in order.
method Seq<A> Somes <A> (this Seq<OptionUnsafe<A>> self) Source #
Extracts from a list of OptionUnsafe
all the Some
elements.
All the Some
elements are extracted in order.
method OptionUnsafe<A> Add <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y) Source #
Add the bound values of x and y, uses an Add type-class to provide the add operation for type A. For example x.Add<TInteger,int>(y)
type | ADD | Add of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | An option with y added to x |
method OptionUnsafe<A> Subtract <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y) Source #
Find the subtract between the two bound values of x and y, uses a Subtract type-class to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)
type | DIFF | Subtract of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | An OptionUnsafe with the subtract between x and y |
method OptionUnsafe<A> Product <ARITH, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y) Source #
Find the product between the two bound values of x and y, uses a Product type-class to provide the product operation for type A. For example x.Product<TInteger,int>(y)
type | PROD | Product of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | An OptionUnsafe with the product of x and y |
method OptionUnsafe<A> Divide <NUM, A> (this OptionUnsafe<A> x, OptionUnsafe<A> y) Source #
Divide the two bound values of x and y, uses a Divide type-class to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)
type | DIV | Divide of A |
type | A | Bound value type |
param | x | Left hand side of the operation |
param | y | Right hand side of the operation |
returns | An OptionUnsafe x / y |
method OptionUnsafe<B> Apply <A, B> (this OptionUnsafe<Func<A, B>> fab, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method OptionUnsafe<B> Apply <A, B> (this Func<A, B> fab, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method OptionUnsafe<C> Apply <A, B, C> (this OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative a to apply |
param | fb | Applicative b to apply |
returns | Applicative of type FC derived from Applicative of C |
method OptionUnsafe<C> Apply <A, B, C> (this Func<A, B, C> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative a to apply |
param | fb | Applicative b to apply |
returns | Applicative of type FC derived from Applicative of C |
method OptionUnsafe<Func<B, C>> Apply <A, B, C> (this OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> Apply <A, B, C> (this Func<A, B, C> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> Apply <A, B, C> (this OptionUnsafe<Func<A, Func<B, C>>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> Apply <A, B, C> (this Func<A, Func<B, C>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<B> Action <A, B> (this OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Evaluate fa, then fb, ignoring the result of fa
param | fa | Applicative to evaluate first |
param | fb | Applicative to evaluate second and then return |
returns | Applicative of type Option |
method A? ToNullable <A> (this OptionUnsafe<A> ma) Source #
Convert the OptionUnsafe type to a Nullable of A
type | A | Type of the bound value |
param | ma | OptionUnsafe to convert |
returns | Nullable of A |
method IEnumerable<R> Match <T, R> (this IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None ) Source #
Match over a list of OptionUnsafes
type | T | Type of the bound values |
type | R | Result type |
param | list | List of OptionUnsafes to match against |
param | Some | Operation to perform when an OptionUnsafe is in the Some state |
param | None | Operation to perform when an OptionUnsafe is in the None state |
returns | An enumerable of results of the match operations |
method IEnumerable<R> Match <T, R> (this IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None) Source #
Match over a list of OptionUnsafes
type | T | Type of the bound values |
type | R | Result type |
param | list | List of OptionUnsafes to match against |
param | Some | Operation to perform when an Option is in the Some state |
param | None | Default if the list is empty |
returns | An enumerable of results of the match operations |
method Task<B> MatchAsync <A, B> (this OptionUnsafe<A> ma, Func<A, Task<B>> Some, Func<B> None) Source #
Match the two states of the OptionUnsafe and return a promise for a non-null R.
type | B | Return type |
param | Some | Some handler. Must not return null. |
param | None | None handler. Must not return null. |
returns | A promise to return a non-null R |
method Task<B> MatchAsync <A, B> (this OptionUnsafe<A> ma, Func<A, Task<B>> Some, Func<Task<B>> None) Source #
Match the two states of the OptionUnsafe and return a promise for a non-null R.
type | B | Return type |
param | Some | Some handler. Must not return null. |
param | None | None handler. Must not return null. |
returns | A promise to return a non-null R |
method int Sum (this OptionUnsafe<int> a) Source #
Sum the bound value
This is a legacy method for backwards compatibility
param | a | OptionUnsafe of int |
returns | The bound value or 0 if None |
method A Sum <NUM, A> (this OptionUnsafe<A> self) Source #
Sum the bound value
This is a legacy method for backwards compatibility
param | self | Option of A that is from the type-class NUM |
returns | The bound value or 0 if None |
method Task<OptionUnsafe<B>> MapAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, Task<B>> map) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | map | Projection function |
returns | Mapped functor |
method Task<OptionUnsafe<B>> MapAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, B> map) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | map | Projection function |
returns | Mapped functor |
method Task<OptionUnsafe<B>> MapAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, B> map) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | map | Projection function |
returns | Mapped functor |
method Task<OptionUnsafe<B>> MapAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, Task<B>> map) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | map | Projection function |
returns | Mapped functor |
method Task<OptionUnsafe<B>> BindAsync <A, B> (this OptionUnsafe<A> self, Func<A, Task<OptionUnsafe<B>>> bind) Source #
Monad bind operation
method Task<OptionUnsafe<B>> BindAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, Task<OptionUnsafe<B>>> bind) Source #
Monad bind operation
method Task<OptionUnsafe<B>> BindAsync <A, B> (this Task<OptionUnsafe<A>> self, Func<A, OptionUnsafe<B>> bind) Source #
Monad bind operation
method Task<OptionUnsafe<B>> BindAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, OptionUnsafe<B>> bind) Source #
Monad bind operation
method Task<OptionUnsafe<B>> BindAsync <A, B> (this OptionUnsafe<Task<A>> self, Func<A, Task<OptionUnsafe<B>>> bind) Source #
Monad bind operation
method Task<Unit> IterAsync <A> (this Task<OptionUnsafe<A>> self, Action<A> Some) Source #
Invoke an action for the bound value (if in a Some state)
param | Some | Action to invoke |
method Task<Unit> IterAsync <A> (this OptionUnsafe<Task<A>> self, Action<A> Some) Source #
Invoke an action for the bound value (if in a Some state)
param | Some | Action to invoke |
method Task<int> CountAsync <A> (this Task<OptionUnsafe<A>> self) Source #
Return the number of bound values in this structure:
None = 0
Some = 1
returns |
method Task<S> FoldAsync <A, S> (this Task<OptionUnsafe<A>> self, S state, Func<S, A, S> folder) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | folder | Folder function, applied if OptionUnsafe is in a Some state |
returns | The aggregate state |
method Task<S> FoldAsync <A, S> (this OptionUnsafe<Task<A>> self, S state, Func<S, A, S> folder) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | folder | Folder function, applied if OptionUnsafe is in a Some state |
returns | The aggregate state |
method Task<bool> ForAllAsync <A> (this Task<OptionUnsafe<A>> self, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied. |
method Task<bool> ForAllAsync <A> (this OptionUnsafe<Task<A>> self, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied. |
method Task<bool> ExistsAsync <A> (this Task<OptionUnsafe<A>> self, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method Task<bool> ExistsAsync <A> (this OptionUnsafe<Task<A>> self, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method OptionUnsafe<T> subtract <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs) Source #
Subtract the Ts
param | lhs | Left-hand side of the operation |
param | rhs | Right-hand side of the operation |
returns | lhs - rhs |
method OptionUnsafe<T> product <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs) Source #
method OptionUnsafe<T> divide <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs) Source #
Divide the Ts
param | lhs | Left-hand side of the operation |
param | rhs | Right-hand side of the operation |
returns | lhs / rhs |
method OptionUnsafe<T> add <NUM, T> (OptionUnsafe<T> lhs, OptionUnsafe<T> rhs) Source #
Add the Ts
param | lhs | Left-hand side of the operation |
param | rhs | Right-hand side of the operation |
returns | lhs / rhs |
method bool isSome <T> (OptionUnsafe<T> value) Source #
Check if OptionUnsafe is in a Some state
type | T | T |
param | value | OptionUnsafe |
returns | True if value is in a Some state |
method bool isNone <T> (OptionUnsafe<T> value) Source #
Check if OptionUnsafe is in a None state
type | T | T |
param | value | OptionUnsafe |
returns | True if value is in a None state |
method OptionUnsafe<T> SomeUnsafe <T> (T value) Source #
Create a Some
of T
(OptionUnsafe<T>
)
type | T | T |
param | value | Non-null value to be made optional |
returns | OptionUnsafe |
method OptionUnsafe<T> SomeUnsafe <T> (Func<Unit, T> f) Source #
Create a lazy Some
of T
(OptionUnsafe<T>
)
type | T | T |
param | value | Non-null value to be made optional |
returns | Option |
method Unit ifSomeUnsafe <T> (OptionUnsafe<T> option, Action<T> Some) Source #
Invokes the action if OptionUnsafe is in the Some state, otherwise nothing happens.
param | f | Action to invoke if OptionUnsafe is in the Some state |
method T ifNoneUnsafe <T> (OptionUnsafe<T> option, Func<T> None) Source #
Returns the result of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned.
Will not accept a null return value from the None operation
param | None | Operation to invoke if the structure is in a None state |
returns | Tesult of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned. |
method T ifNoneUnsafe <T> (OptionUnsafe<T> option, T noneValue) Source #
Returns the noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned.
Will not accept a null noneValue
param | noneValue | Value to return if in a None state |
returns | noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned |
method R matchUnsafe <T, R> (OptionUnsafe<T> option, Func<T, R> Some, Func<R> None) Source #
Match the two states of the OptionUnsafe and return a B, which can be null.
type | B | Return type |
param | Some | Some match operation. May return null. |
param | None | None match operation. May return null. |
returns | B, or null |
method Unit matchUnsafe <T> (OptionUnsafe<T> option, Action<T> Some, Action None) Source #
Match the two states of the OptionUnsafe
param | Some | Some match operation |
param | None | None match operation |
method OptionUnsafe<B> apply <A, B> (OptionUnsafe<Func<A, B>> fab, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method OptionUnsafe<B> apply <A, B> (Func<A, B> fab, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type FB derived from Applicative of B |
method OptionUnsafe<C> apply <A, B, C> (OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative a to apply |
param | fb | Applicative b to apply |
returns | Applicative of type FC derived from Applicative of C |
method OptionUnsafe<C> apply <A, B, C> (Func<A, B, C> fabc, OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative a to apply |
param | fb | Applicative b to apply |
returns | Applicative of type FC derived from Applicative of C |
method OptionUnsafe<Func<B, C>> apply <A, B, C> (OptionUnsafe<Func<A, B, C>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> apply <A, B, C> (Func<A, B, C> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> apply <A, B, C> (OptionUnsafe<Func<A, Func<B, C>>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<Func<B, C>> apply <A, B, C> (Func<A, Func<B, C>> fabc, OptionUnsafe<A> fa) Source #
Apply
param | fab | Function to apply the applicative to |
param | fa | Applicative to apply |
returns | Applicative of type f(b -> c) derived from Applicative of Func<B, C> |
method OptionUnsafe<B> action <A, B> (OptionUnsafe<A> fa, OptionUnsafe<B> fb) Source #
Evaluate fa, then fb, ignoring the result of fa
param | fa | Applicative to evaluate first |
param | fb | Applicative to evaluate second and then return |
returns | Applicative of type Option |
method S fold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> folder) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | folder | Folder function, applied if OptionUnsafe is in a Some state |
returns | The aggregate state |
method S bifold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> Some, Func<S, S> None) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | Some | Folder function, applied if OptionUnsafe is in a Some state |
param | None | Folder function, applied if OptionUnsafe is in a None state |
returns | The aggregate state |
method S bifold <S, A> (OptionUnsafe<A> option, S state, Func<S, A, S> Some, Func<S, Unit, S> None) Source #
OptionUnsafe types are like lists of 0 or 1 items, and therefore follow the same rules when folding.
In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.
type | S | Aggregate state type |
param | state | Initial state |
param | Some | Folder function, applied if OptionUnsafe is in a Some state |
param | None | Folder function, applied if OptionUnsafe is in a None state |
returns | The aggregate state |
method bool forall <A> (OptionUnsafe<A> option, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied.
param | pred | Predicate to apply |
returns | If the OptionUnsafe is in a None state then True is returned (because the predicate applies for-all values). If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the predicate supplied. |
method bool biforall <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool biforall <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method int count <A> (OptionUnsafe<A> option) Source #
Return the number of bound values in this structure:
None = 0
Some = 1
returns |
method bool exists <A> (OptionUnsafe<A> option, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | pred | Predicate to apply |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool biexists <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method bool biexists <A> (OptionUnsafe<A> option, Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
param | Some | Predicate to apply if in a Some state |
param | None | Predicate to apply if in a None state |
returns | If the OptionUnsafe is in a None state then True is returned if invoking None returns True. If the OptionUnsafe is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. |
method OptionUnsafe<B> map <A, B> (OptionUnsafe<A> option, Func<A, B> f) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | f | Projection function |
returns | Mapped functor |
method OptionUnsafe<B> bimap <A, B> (OptionUnsafe<A> option, Func<A, B> Some, Func<B> None) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | Some | Projection function |
param | None | Projection function |
returns | Mapped functor |
method OptionUnsafe<B> bimap <A, B> (OptionUnsafe<A> option, Func<A, B> Some, Func<Unit, B> None) Source #
Projection from one value to another
type | B | Resulting functor value type |
param | Some | Projection function |
param | None | Projection function |
returns | Mapped functor |
method OptionUnsafe<Func<T2, R>> parmap <T1, T2, R> (OptionUnsafe<T1> option, Func<T1, T2, R> mapper) Source #
Partial application map
method OptionUnsafe<Func<T2, Func<T3, R>>> parmap <T1, T2, T3, R> (OptionUnsafe<T1> option, Func<T1, T2, T3, R> mapper) Source #
Partial application map
method OptionUnsafe<T> filter <T> (OptionUnsafe<T> option, Func<T, bool> pred) Source #
Apply a predicate to the bound value (if in a Some state)
param | pred | Predicate to apply |
returns | Some(x) if the OptionUnsafe is in a Some state and the predicate returns True. None otherwise. |
method OptionUnsafe<R> bind <T, R> (OptionUnsafe<T> option, Func<T, OptionUnsafe<R>> binder) Source #
Monadic bind operation
method IEnumerable<R> matchUnsafe <T, R> (IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None ) Source #
Match the two states of the list of OptionUnsafes
param | Some | Some match operation |
param | None | None match operation |
method IEnumerable<R> matchUnsafe <T, R> (IEnumerable<OptionUnsafe<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None ) Source #
Match the two states of the list of OptionUnsafes
param | Some | Some match operation |
param | None | None match operation |
method IEnumerable<T> somes <T> (IEnumerable<OptionUnsafe<T>> list) Source #
Extracts from a list of 'OptionUnsafe' all the 'Some' elements. All the 'Some' elements are extracted in order.