This project is read-only.


Monadic creates monad types for C# in a C# specific manner.

This is my own research project to express a few ideas I've been having. I have decided to let it take me where it will and much what is put it in here may not seem practical. If you would like to contribute to this exploration, send me an email... or blog about it!

The List monad is well represented with the extension methods on IEnumerable<T> in LINQ to Objects. I have found that others usually create classes to represent the Bind and Return interface used by monads, but I feel the best way to achieve the functionality of monads in C# is to do it the C# way: with extension methods on existing types. The initial checkin provides the Identity and Maybe monads using extension methods on object.

IEEE ICCSIT 2010 Visitors

The presentation is posted on my blog.
Learn more about query expressions.

If you're from Chengdu, visit the local .NET user group.
If you're from elsewhere in the Asia-Pacific area, visit the INETA website to find a local .NET user group.

Monadic - LINQ to Object


var result = from x in 7
select x;

Assert.AreEqual(7, result);


var result = from x in 0
where x != 0
select x;

Assert.AreEqual(null, result);

Assert.AreEqual(0, result ?? 0);

Functive - LINQ to Funcs

Functive provides a way to combine functions together using linq query expressions.

Func<int, int> square = x => x * x;

var hypoteneuse = from h in square
from w in square
select Math.Sqrt(h + w);

Assert.AreEqual(5, hypoteneuse(3, 4));

Last edited Jul 10, 2010 at 8:16 AM by KodefuGuru, version 6