Maybe<T>

Coordinator
Jun 27, 2010 at 11:27 PM

C# doesn't currently support overloading by generic constraints, thereby preventing returning a Nullable<T> in the case of structs and null for classes. Query expressions also don't support query expressions for type of dynamic, outside of returning one, as I did for Where. Therefore, I think it will be necessary to represent the Maybe monad with an actual type. This is unfortunate, as I had hoped to get away with using built-in CLR types for all expressions.

Here's for hoping generic constraint overloading makes it in C# 5. For now, we need the best candidate for Maybe<T>.