Posts Tagged ‘monads’

The Maybe Monad in C#

December 11, 2008 6 comments

The Maybe Monad is extremely simple. It represents a value that might be there, but might not, and also provides a neat way of working with such values.

This Haskell-related page makes it pretty clear:

The Maybe monad embodies the strategy of combining a chain of computations that may each return Nothing by ending the chain early if any step produces Nothing as output. It is useful when a computation entails a sequence of steps that depend on one another, and in which some steps may fail to return a value.

Change Nothing to null and we’re talking in C#. Furthermore, it advises:
Read more…

Categories: C#, generics, monads Tags: , ,

The Magic Word: Monad

November 27, 2008 Leave a comment

Since writing this post a few weeks ago – which now seems ridiculously naive when I read it back – I set off on a journey to discover the motivations behind the features of Linq. Eventually I cottoned on to the magic work: monad.

Once you know to add monad to your Google search terms, it’s like an undocumented modifier that makes the search results about 38 times as interesting as they would otherwise be.

It turns out that lots of people have been raving about monads for years, and meanwhile I’ve been thinking about them without knowing what to call them (apparently quite a common experience).

Read more…

Categories: monads Tags: