
On Wed, Apr 22, 2009 at 10:38:14PM +0200, Daniel Carrera wrote:
Hello,
I have finished the tutorial at http://ertes.de/articles/monads.html and my understanding of monads has increased greatly. I still need to cement some concepts in my mind. What exactly is the difference between a computation and a function? Monads revolve around computations, so I'd like to understand computations better.
"Computation" does not really have any technical meaning, it's just supposed to be an intuition. But the term "computation" is often used to refer to things of type (m a) where m is a Monad. You can clearly see from the types that something of type (m a) is different than something of type (a -> b). The former takes no inputs and somehow produces value(s) of type a; the latter takes something of type a as input and produces something of type b as output. However, you could also legitimately thing of things of type (a -> b) as "computations"; more interestingly, you can think of things of type (a -> m b) as "parameterized computations" which can be composed in nice ways. Don't rely too heavily on the "computation" idea; monads certainly don't "revolve around computations", it's only one particular way of giving intuition for monads which does. -Brent