Skip to content

Instantly share code, notes, and snippets.

@srdjan
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srdjan/6161c5e8a3baa1e83aca to your computer and use it in GitHub Desktop.
Save srdjan/6161c5e8a3baa1e83aca to your computer and use it in GitHub Desktop.
static void Main(string[] args) {
//-1) Maybe monad usage: input regular string, intermediate result int...
var maybeM = new MaybeM<string>("I'm a string, wrapped up in the Maybe Monad!");
var result1 = maybeM.Bind(ExtractVowels)
.Bind(Length);
WriteLine("Result is: \{result1.Show()}");
//-2) Maybe monad usage: null string
maybeM = new MaybeM<string>(null);
var result2 = maybeM.Bind(ExtractVowels)
.Bind(Length);
WriteLine("Result is: \{result2.Show()}");
//-3) Writer monad usage
var writerM = new WriterM<string>("I'm a string, wrapped up in the Maybe Monad!");
var result3 = writerM.Bind(ExtractVowels)
.Bind(Length);
WriteLine("Result is: \{result3.Show()}");
ReadLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment