[Haskell-cafe] Functional vs Imperative

David Roundy droundy at abridgegame.org
Tue Sep 13 11:22:27 EDT 2005

On Tue, Sep 13, 2005 at 01:45:52PM +0000, Dhaemon wrote:
> Also, just for kicks, may I had this: I read the code of some haskell-made 
> programs and was astonished. Yes! It was clean and all, but there were "do"s 
> everywhere... Why use a function language if you use it as an imperative 
> one?(i.e. most of the apps in http://haskell.org/practice.html)

Monadic code isn't synonymous with imperative code, and "do" only indicates
that you're looking at monadic code.  The Maybe monad is an example of a
very useful, very non-imperative monad that can be used to cleanly write
functional code.

On the other hand, IO is always monadic, so perhaps you're looking at IO
code.  But I'd assert that even monadic IO code isn't quite the same as
true "imperative" code.  I'd probably say that the difference has to do
with whether you create modifiable "variables".  When you start doing that,
whether you're in the ST monad or the IO monad, I think you're writing
imperative-style code.  But I think that that sort of usage is actually
pretty uncommon.
David Roundy

More information about the Haskell-Cafe mailing list