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