Tech Off Post

Single Post Permalink

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

    John, he's not asking for a solution to anything. He's trying to understand the concept of monads. Unfortunately, I'm sitting at about a 70% understanding right now, which is maybe a little less than Thorium already has.

    Thorium, I'm just going to make a guess here. The reality is that you can implement pretty much any part of LINQ given just one or two existing operators. However, from the viewpoint of monads, only SelectMany represents the "bind operation" (from Wikipedia):

    A binding operation of polymorphic type (M t)→(t→M u)→(M u), which Haskell represents by the infix operator >>=. Its first argument is a value in a monadic type, its second argument is a function that maps from the underlying type of the first argument to another monadic type, and its result is in that other monadic type. Typically, the binding operation can be understood as having four stages:

    1. The monad-related structure on the first argument is "pierced" to expose any number of values in the underlying type t.
    2. The given function is applied to all of those values to obtain values of type (M u).
    3. The monad-related structure on those values is also pierced, exposing values of type u.
    4. Finally, the monad-related structure is reassembled over all of the results, giving a single value of type (M u).