Top ASP.NET Items

Sponsors

Oh yeah, CallStream is great to express monads

It has been pointed out by several commenters that CallStream was a reinvention of monads. Not quite so, but the nuance is subtle. CallStream is a pattern to express chain-callable APIs. That makes it possible to express monads with CallStream , but in the same way that JavaScript functions and C# delegates do. Expressing monads with CallStreams can be done in a way that is quite expressive, but let me switch from the usual C# to JavaScript for that (I can’t think of a strongly-typed C# expression of the same thing, but feel free to prove me wrong in the comments). Here’s the code for the monad: function identity(value) { var bind = function (operation) { return operation(value); } bind.value = value; return bind; } And here’s how you would Read More...

Read the complete post at http://weblogs.asp.net/bleroy/archive/2010/07/01/oh-yeah-callstream-is-great-to-express-monads.aspx