[Haskell-beginners] Re: computation vs function

Daniel Carrera daniel.carrera at theingots.org
Thu Apr 23 05:32:41 EDT 2009

Ertugrul Soeylemez wrote:
> What I refer to as a 'computation' in the article is actually just a
> value of type 'Monad m => m a'.  I have chosen that term, because you
> can apply it to any monad I've seen.  As mentioned in section 5, you can
> think of 'Just 3' as being a computation, which results in 3.  But it's
> important that this is not a function, but just an independent value.


I think the article would benefit from making the meaning of computation 
clearer. The word computation appears in the tutorial 51 times before 
section 5. That means that when I tried to go back for a definition of 
computation I couldn't find one.

The first place you use the word computation is in the preamble, but 
that's not a good place to define terms. The second time you use the 
word computation is in section 2 "Motivation". This might be a good 
place to define the term. The Motivation section already defines several 
terms (referentially transparent, purely functional, etc), so it seems 
like a good place to define computation as well.

In section 2 we can't say "Monad => m a" or "Just 3" because the terms 
are not introduced yet. Perhaps you could say something like this:

The word 'computation' here is not a technical term. I use it to refer 
to something that returns a value without taking in any parameters. For 
example (m a) is a computation that takes no parameters but returns a 
value of type 'a' whereas (a -> b) is a function that takes a parameter 
of type 'a' and returns a value of type 'b'. It is important that a 
computation is not a function, but an independent value.

I think that adding that as the third paragraph in the Motivation 
section would be helpful. In addition, in the Preamble, when you use the 
word computation, I would add "(see next section)".

Question: Would it be reasonable to say that a computation is a wrapper? 
I'm not sure, because I don't know if a computation always results in 
the *same* value (you know, side-effects). I know that "Just 3" always 
results in 3, but is that universal?


More information about the Beginners mailing list