Tech Off Post

Single Post Permalink

View Thread: LINQ Where; fold vs bind...
  • User profile image
    Thorium

    Maybe I wasn't clear...

    The "predicate(s)" is just anything that holds the definition of the Where predicate:

     Func<TSource, bool> predicate

    The "selector(s)" is just anything that holds the definition of the SelectMany selector:

    Func<TSource, IEnumerable<TResult>> selector

    The concrete implementation doesn't matter.

    ---

    Fold / Aggregate is a kind of visitor pattern to visit every item of the container (monad).

    ---

    The SelectMany (monadic bind) syntax is something like this:

    M<A> -> (A -> M<B>) -> M<B>

    LINQ deals with immutable collections. So M<A> is not altered/transformed. Instead someone will know how to create a new M<B>. And applying this (A->M<B>) will mean that there must be a way to get A from M<A>. That will need some kind of visitor pattern.