In the previous examples, the query comprehension can work on any monad. Types declare their
monad simply by implementing the SelectMany
(and Select
) method.
Notice that a general LINQ query comprehension cannot have a type since it would require higher-order polymorphism. Consequently, we cannot write functions to run on any monad.
C# is catching up to practical languages (unlike Java), but still has an awful long way to go!