Skip to content

Instantly share code, notes, and snippets.

@dimitris-papadimitriou-chr
Created July 10, 2020 17:33
Show Gist options
  • Select an option

  • Save dimitris-papadimitriou-chr/b69d2e2aebf524af9bf948174102bcc2 to your computer and use it in GitHub Desktop.

Select an option

Save dimitris-papadimitriou-chr/b69d2e2aebf524af9bf948174102bcc2 to your computer and use it in GitHub Desktop.
public static class FunctionalExtensions
{
public static Maybe<T1> Bind<T, T1>(this Maybe<T> @this, Func<T, Maybe<T1>> f) =>
@this switch
{
None<T> { } => new None<T1>(),
Some<T> { Value: var v } => f(v),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment