Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Created April 4, 2011 02:24
Show Gist options
  • Save mikeobrien/901058 to your computer and use it in GitHub Desktop.
Save mikeobrien/901058 to your computer and use it in GitHub Desktop.
public static class MaybeMonadicExtensions
{
public static Maybe<T> ToMaybe<T>(this T value)
{
return value == null ? Maybe.Nothing<T>() : Maybe.Just(value);
}
public static Maybe<B> Bind<A, B>(this Maybe<A> a, Func<A, Maybe<B>> func)
{
return a.HasValue ? func(a.Value) : Maybe.Nothing<B>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment