
On Wed, 2009-04-22 at 22:38 +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.
Computations are like "procedures" in other languages - you run them[1],
they yield a value. Conceptually, functions are (potentially infinite)
maps from their input to their output. We sometimes call functions with
types like "Int -> IO ()" monadic functions as well, which may also mean
the combination of the function and then the computation that results -
by analogy to functions in languages like C.
[1] Sometimes the runtime system runs them for you, like main. Sometimes
the computation is already its (lazily evaluated) output, like with
lists or Maybe.
--
Philippa Cowderoy