Beispiel #1
0
 /// <summary>
 /// Create a Some of T from a Nullable<T> (Option<T>)
 /// </summary>
 /// <typeparam name="T">T</typeparam>
 /// <param name="value">Non-null value to be made optional</param>
 /// <returns>Option<T> in a Some state or throws ValueIsNullException
 /// if value == null</returns>
 public static Option <T> Some <T>(Nullable <T> value) where T : struct =>
 value.HasValue
         ? Option <T> .Some(value.Value)
 : raise <Option <T> >(new ValueIsNullException());
Beispiel #2
0
 public Option <B> Map <B>(Func <A, B> f) =>
 isSome
         ? Option <B> .Some(f(Value))
         : default;
Beispiel #3
0
 /// <summary>
 /// Create a Some of T (Option<T>)
 /// </summary>
 /// <typeparam name="T">T</typeparam>
 /// <param name="value">Non-null value to be made optional</param>
 /// <returns>Option<T> in a Some state or throws ValueIsNullException
 /// if value == null.</returns>
 public static Option <T> Some <T>(T value) =>
 value == null
         ? raise <Option <T> >(new ValueIsNullException())
         : Option <T> .Some(value);
Beispiel #4
0
 public static Option <Identity <B> > Traverse <A, B>(this Identity <Option <A> > ma, Func <A, B> f) =>
 ma.Value.IsSome
         ? Option <Identity <B> > .Some(new Identity <B>(f(ma.Value.Value)))
         : Option <Identity <B> > .None;