[Haskell-cafe] Functional vs Imperative

Sebastian Sylvan sebastian.sylvan at gmail.com
Tue Sep 13 12:35:12 EDT 2005


On 9/13/05, Dhaemon <dhaemon at gmail.com> wrote:
> Hello,
>  I'm quite interested in haskell, but there is something I don't
> understand(intuitively). I've been crawling the web for an answer, but
> nothing talks to me...
>  So I was hoping I could find some help here:
>  "How is evaluating an expression different from performing action?"
>  I'm puzzled... Doesn't it amount to the same thing? Maybe I have a wrong
> definition of "evaluating"(determine the value of an expression)?
>  Examples would be appreciated.
>  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)
>  

Well, most of the code is still "functional" in nature, only some of
it is "imperative".
And even if you're writing a very IO heavy program writing IO in
Haskell is still much nicer than in traditional imperative languages
since all actions are first class citizens etc.

It's better to have a nice clean way of doing IO that's completely
separated away from pure code than to have everything be done in a
less clean imperative style always.
In Haskell you have it both ways. When a functional approach is
cleaner, use it, when stuff should be evaluated in sequence (not just
IO, but other monads like Maybe and State as well) you do that. It all
works out in a sane and clean way.

/S

-- 
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862


More information about the Haskell-Cafe mailing list