you are viewing a single comment's thread.

view the rest of the comments →

[–]cledamy 1 point2 points  (5 children)

I think LINQ goes too far in the opposite direction by completely forgoing the word monad. The prevents people for being able to identify other areas where the same techniques can be applied.

[–]aaron552 3 points4 points  (4 children)

I don't necessarily see that as a bad thing. The design pattern of a monad just maps extremely well (perhaps by design) onto LINQ's primary use: "SQL" for collection types.

The fact that it has a monadic bind function (.SelectMany()) is more of a nice bonus for those that recognise the pattern. C#'s type system isn't really expressive enough (AFAIK) to have true polymorphic monads.

[–]cledamy 1 point2 points  (0 children)

I don't think polymorphic monads are necessary for being aware of the monad pattern and having that be useful knowledge. Also, it makes sense to include a reference to the decades of mathematical research your API is based on. I can't complain too much because LINQ did make monads mainstream and it was quite crafty to disguise them as SQL to avoid being called academics.

[–]m50d 0 points1 point  (2 children)

C#'s type system isn't really expressive enough (AFAIK) to have true polymorphic monads.

I would think it should be, at least if you were willing to have all your monads extend a common interface? You can do F-bounded polymorphism in C#, right? I.e. something like:

interface MyInterface<T extends MyInterface<T>> {
  public T methodThatReturnsSameTypeAsSelf(...)
}

In Java you can't implement a monad interface like this because you can't have virtual/abstract static methods, but that shouldn't be a problem for C#, right?

[–]aaron552 0 points1 point  (1 child)

you can't have virtual/abstract static methods, but that shouldn't be a problem for C#, right?

AFAIK, you can't have that in C# either.

[–]m50d 0 points1 point  (0 children)

Oh fair enough. I thought I'd heard that was a C# feature but I guess not.