Contents
- Prelude
- flatten <A> (Option<Option<A>> ma)
- subtract <NUM, T> (Option<T> lhs, Option<T> rhs)
- product <NUM, T> (Option<T> lhs, Option<T> rhs)
- divide <NUM, T> (Option<T> lhs, Option<T> rhs)
- add <NUM, T> (Option<T> lhs, Option<T> rhs)
- isSome <T> (Option<T> value)
- isNone <T> (Option<T> value)
- None = new (default)
- Some <A> (A value)
- Some <A> (A? value)
- Optional <A> (A? value)
- Optional <A> (A? value)
- ifSome <T> (Option<T> option, Action<T> Some)
- ifNone <T> (Option<T> option, Func<T> None)
- ifNone <T> (Option<T> option, T noneValue)
- match <T, R> (Option<T> option, Func<T, R> Some, Func<R> None)
- match <T> (Option<T> option, Action<T> Some, Action None)
- bifold <S, A> (Option<A> option, S state, Func<S, A, S> Some, Func<S, S> None)
- bifold <S, A> (Option<A> option, S state, Func<S, A, S> Some, Func<S, Unit, S> None)
- forall <A> (Option<A> option, Func<A, bool> pred)
- biforall <A> (Option<A> option, Func<A, bool> Some, Func<Unit, bool> None)
- biforall <A> (Option<A> option, Func<A, bool> Some, Func<bool> None)
- count <A> (Option<A> option)
- exists <A> (Option<A> option, Func<A, bool> pred)
- biexists <A> (Option<A> option, Func<A, bool> Some, Func<Unit, bool> None)
- biexists <A> (Option<A> option, Func<A, bool> Some, Func<bool> None)
- map <A, B> (Option<A> option, Func<A, B> f)
- bimap <A, B> (Option<A> option, Func<A, B> Some, Func<B> None)
- bimap <A, B> (Option<A> option, Func<A, B> Some, Func<Unit, B> None)
- filter <T> (Option<T> option, Func<T, bool> pred)
- bind <T, R> (Option<T> option, Func<T, Option<R>> binder)
- match <T, R> ( IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None)
- match <T, R> (IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None)
- somes <T> (IEnumerable<Option<T>> list)
- toList <T> (Option<T> option)
- toArray <T> (Option<T> option)
- Prelude
Fields
field Fail<Unit> None = new (default) Source #
'No value' state of Option T.
Methods
method Option<T> subtract <NUM, T> (Option<T> lhs, Option<T> rhs) Source #
Subtract the Ts
Parameters
| param | lhs | Left-hand side of the operation |
| param | rhs | Right-hand side of the operation |
| returns | lhs - rhs | |
method Option<T> product <NUM, T> (Option<T> lhs, Option<T> rhs) Source #
Find the product of the Ts
method Option<T> divide <NUM, T> (Option<T> lhs, Option<T> rhs) Source #
Divide the Ts
Parameters
| param | lhs | Left-hand side of the operation |
| param | rhs | Right-hand side of the operation |
| returns | lhs / rhs | |
method Option<T> add <NUM, T> (Option<T> lhs, Option<T> rhs) Source #
Add the Ts
Parameters
| param | lhs | Left-hand side of the operation |
| param | rhs | Right-hand side of the operation |
| returns | lhs / rhs | |
method bool isSome <T> (Option<T> value) Source #
Check if Option is in a Some state
Parameters
| type | T | T |
| param | value | Option |
| returns | True if value is in a Some state | |
method bool isNone <T> (Option<T> value) Source #
Check if Option is in a None state
Parameters
| type | T | T |
| param | value | Option |
| returns | True if value is in a None state | |
method Option<A> Some <A> (A value) Source #
Create a Some of A
Parameters
| type | A | Bound value type |
| param | value | Non-null value to be made optional |
| returns |
| |
method Option<A> Some <A> (A? value) Source #
Create a Some of A from a Nullable〈A〉
Parameters
| type | A | Bound value type |
| param | value | Non-null value to be made optional |
| returns |
| |
method Option<A> Optional <A> (A? value) Source #
Create an Option of A
Parameters
| type | A | Bound value type |
| param | value | Value to be made optional, or |
| returns | If the value is | |
method Option<A> Optional <A> (A? value) Source #
Create an Option of A
Parameters
| type | A | Bound value type |
| param | value | Value to be made optional, or null |
| returns | If the value is | |
method Unit ifSome <T> (Option<T> option, Action<T> Some) Source #
Invokes the action if Option is in the Some state, otherwise nothing happens.
Parameters
| param | f | Action to invoke if Option is in the Some state |
method T ifNone <T> (Option<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
Parameters
| param | None | Operation to invoke if the structure is in a None state |
| returns | Result of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned. | |
method T ifNone <T> (Option<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
Parameters
| 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 match <T, R> (Option<T> option, Func<T, R> Some, Func<R> None) Source #
Match the two states of the Option and return a non-null R.
Parameters
| type | B | Return type |
| param | Some | Some match operation. Must not return null. |
| param | None | None match operation. Must not return null. |
| returns | A non-null B | |
method Unit match <T> (Option<T> option, Action<T> Some, Action None) Source #
Match the two states of the Option
Parameters
| param | Some | Some match operation |
| param | None | None match operation |
method S bifold <S, A> (Option<A> option, S state, Func<S, A, S> Some, Func<S, S> None) Source #
Option 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.
Parameters
| type | S | Aggregate state type |
| param | state | Initial state |
| param | Some | Folder function, applied if Option is in a Some state |
| param | None | Folder function, applied if Option is in a None state |
| returns | The aggregate state | |
method S bifold <S, A> (Option<A> option, S state, Func<S, A, S> Some, Func<S, Unit, S> None) Source #
Option 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.
Parameters
| type | S | Aggregate state type |
| param | state | Initial state |
| param | Some | Folder function, applied if Option is in a Some state |
| param | None | Folder function, applied if Option is in a None state |
| returns | The aggregate state | |
method bool forall <A> (Option<A> option, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned (because the predicate applies for-all values). If the Option is in a Some state the value is the result of running applying the bound value to the predicate supplied.
Parameters
| param | pred | Predicate to apply |
| returns | If the Option is in a None state then True is returned (because the predicate applies for-all values). If the Option is in a Some state the value is the result of running applying the bound value to the predicate supplied. | |
method bool biforall <A> (Option<A> option, Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
Parameters
| param | Some | Predicate to apply if in a Some state |
| param | None | Predicate to apply if in a None state |
| returns | If the Option is in a None state then True is returned if invoking None returns True. If the Option 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> (Option<A> option, Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
Parameters
| param | Some | Predicate to apply if in a Some state |
| param | None | Predicate to apply if in a None state |
| returns | If the Option is in a None state then True is returned if invoking None returns True. If the Option 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> (Option<A> option) Source #
Return the number of bound values in this structure:
None = 0
Some = 1
Parameters
| returns | ||
method bool exists <A> (Option<A> option, Func<A, bool> pred) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
Parameters
| param | pred | Predicate to apply |
| returns | If the Option is in a None state then True is returned if invoking None returns True. If the Option 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> (Option<A> option, Func<A, bool> Some, Func<Unit, bool> None) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
Parameters
| param | Some | Predicate to apply if in a Some state |
| param | None | Predicate to apply if in a None state |
| returns | If the Option is in a None state then True is returned if invoking None returns True. If the Option 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> (Option<A> option, Func<A, bool> Some, Func<bool> None) Source #
Apply a predicate to the bound value. If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied.
Parameters
| param | Some | Predicate to apply if in a Some state |
| param | None | Predicate to apply if in a None state |
| returns | If the Option is in a None state then True is returned if invoking None returns True. If the Option is in a Some state the value is the result of running applying the bound value to the Some predicate supplied. | |
method Option<B> map <A, B> (Option<A> option, Func<A, B> f) Source #
Projection from one value to another
Parameters
| type | B | Resulting functor value type |
| param | f | Projection function |
| returns | Mapped functor | |
method Option<B> bimap <A, B> (Option<A> option, Func<A, B> Some, Func<B> None) Source #
Projection from one value to another
Parameters
| type | B | Resulting functor value type |
| param | Some | Projection function |
| param | None | Projection function |
| returns | Mapped functor | |
method Option<B> bimap <A, B> (Option<A> option, Func<A, B> Some, Func<Unit, B> None) Source #
Projection from one value to another
Parameters
| type | B | Resulting functor value type |
| param | Some | Projection function |
| param | None | Projection function |
| returns | Mapped functor | |
method Option<T> filter <T> (Option<T> option, Func<T, bool> pred) Source #
Apply a predicate to the bound value (if in a Some state)
Parameters
| param | pred | Predicate to apply |
| returns | Some(x) if the Option is in a Some state and the predicate returns True. None otherwise. | |
method Option<R> bind <T, R> (Option<T> option, Func<T, Option<R>> binder) Source #
Monadic bind operation
method IEnumerable<R> match <T, R> ( IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None) Source #
Match the two states of the list of Options
Parameters
| param | Some | Some match operation |
| param | None | None match operation |
method IEnumerable<R> match <T, R> (IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None) Source #
Match the two states of the list of Options
Parameters
| param | Some | Some match operation |
| param | None | None match operation |
method IEnumerable<T> somes <T> (IEnumerable<Option<T>> list) Source #
Extracts from a list of 'Option' all the 'Some' elements. All the 'Some' elements are extracted in order.
Methods
method Option<B> map <A, B> (Func<A, B> f, K<Option, A> ma) Source #
Functor map operation
Unwraps the value within the functor, passes it to the map function f provided, and
then takes the mapped value and wraps it back up into a new functor.
Parameters
| param | ma | Functor to map |
| param | f | Mapping function |
| returns | Mapped functor | |
method Option<B> action <A, B> (K<Option, A> ma, K<Option, B> mb) Source #
Applicative action: runs the first applicative, ignores the result, and returns the second applicative
method Option<B> apply <A, B> (K<Option, Func<A, B>> mf, K<Option, A> ma) Source #
Applicative functor apply operation
Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and
then takes the resulting value and wraps it back up into a new applicative-functor.
Parameters
| param | ma | Value(s) applicative functor |
| param | mf | Mapping function(s) |
| returns | Mapped applicative functor | |