[Haskell-cafe] Robert Harper on monads and laziness
Ketil Malde
ketil at malde.org
Mon May 2 09:54:53 CEST 2011
I'm following Harper's blog, Existential Type¹, which I find to be an
enjoyable and entertainingly written tirade about the advantages of
teaching functional programming - specifically ML - to students. Of
course, he tends to be critical of Haskell, but it's nice to get some
thought provoking opinion from somebody who knows a bit about the
business.
Recently, he had a piece on monads, and how to do them in ML, and one
statement puzzled me:
"There is a particular reason why monads had to arise in Haskell,
though, which is to defeat the scourge of laziness."
My own view is/was that monads were so successful in Haskell since it
allowed writing flexible programs with imperative features, without
sacrificing referential transparency. Although people are quick (and
rightly so) to point out that this flexibility goes way beyond IO, I
think IO was in many ways the killer application for monads. Before IO,
we had very limited functionality (like 'interact' taking a 'String ->
String' function and converting it into an exectuable program) to build
real programs from.
Laziness does require referential transparency (or at least, it is
easier to get away with the lack of RT in a strict language), so I can
see that he is indirectly correct, but RT is a goal in itself. Thus, I
wonder if there are any other rationale for a statement like that?
-k
¹ http://existentialtype.wordpress.com/
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list