[Haskell-cafe] Re: Why?

Stefan Monnier monnier at iro.umontreal.ca
Thu Dec 10 21:01:45 EST 2009


> This is a matter that I genuinely at the present time do not grasp and
> I am hoping that some of you who are more familiar with the Haskell
> language may be able to help enlighten me. I feel the question to be
> an important one. What material benefit does Haskell derive from being
> a "pure" functional language as opposed to an impure one? Please
> provide examples as I require instruction.

I think the STM monad is one of the greatest examples of why Haskell's
approach to side-effects is a resounding success.  Without having to
change anything to the language and compiler, i.e. as a mere library
addition (more or less), you get a concurrency system with optimistic
synchronization, where all the needed invariants are trivially enforced
by the type-system:
- no prints or other un-revertable side effects in transactions.
- all accesses to shared variables are protected by a transaction.
- ...
Monads aren't always perfect when it comes to side-effects, but in the
context of STM, they really shine.


        Stefan



More information about the Haskell-Cafe mailing list