Why does application of `sequence` on List of Lists lead to computation of its Cartesian Product?

This works because using lists as monads in Haskell makes them model indeterminism. Consider: sequence [[1,2],[3,4]] By definition this is the same as: do x <- [1,2] y <- [3,4] return [x,y] Just read it as “First a choice between 1 and 2, then a choice between 3 and 4”. The list monad will now … Read more

Monad theory and Haskell

A quick disclaimer: I’m a little shaky on category theory in general, while I get the impression you have at least some familiarity with it. Hopefully I won’t make too much of a hash of this… Does anyone know of a tutorial that starts from category theory and explains IO, state, list monads in those … Read more

Method parameters validation in Scala, with for comprehension and monads

If you’re willing to use Scalaz, it has a handful of tools that make this kind of task more convenient, including a new Validation class and some useful right-biased type class instances for plain old scala.Either. I’ll give an example of each here. Accumulating errors with Validation First for our Scalaz imports (note that we … Read more

How does C# async/await relates to more general constructs, e.g. F# workflows or monads?

The asynchronous programming model in C# is very similar to asynchronous workflows in F#, which are an instance of the general monad pattern. In fact, the C# iterator syntax is also an instance of this pattern, although it needs some additional structure, so it is not just simple monad. Explaining this is well beyond the … Read more

What are the alternative of monads to use IO in pure functional programming?

What alternatives are there to monads for I/O in a pure functional language? I’m aware of two alternatives in the literature: One is a so-called linear type system. The idea is that a value of linear type must be used exactly one time: you can’t ignore it, and you can’t use it twice. With this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)