3 ms·
That rumour seems like it's false, because not only is "implemented using monads" a rather vague qualification, Linq has currently been implemented by requiring
by contravariant 7y ago
That rumour seems like it's false, because not only is "implemented using monads" a rather vague qualification, Linq has currently been implemented by requiring objects to implement the SelectMany function, which has signature:
MyObject<B> SelectMany(MyObject<A>, Func<A, MyObject<B>>)
or perhaps more familiar to the Haskell folks:
SelectMany :: M a -> (a -> M b) -> M b
i.e. exactly the 'bind' operator for Monads.
I think you also need to implement a 'Select :: M a -> M b' operator, rather than a 'return :: a -> M a' operator, which would be closer to a true Monad, but the 'bind' operator is the one that really matters anyway.
- goto11 7y agoThe rumor was that the standard extension methods on IEnumerable<T> like Join, Select, Where, Group were all implemented on top of SelectMany. I call it a rumor because I cannot remember where I read it, so it is quite possible I have misunderstood it.