Last active
August 29, 2015 14:09
-
-
Save srdjan/6161c5e8a3baa1e83aca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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