[Haskell-beginners] computation vs function
flippa at flippac.org
Wed Apr 22 18:01:50 EDT 2009
On Wed, 2009-04-22 at 22:38 +0200, Daniel Carrera wrote:
> 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,
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.
 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 <flippa at flippac.org>
More information about the Beginners