[Haskell-cafe] About print and side-effects
sebastian.sylvan at gmail.com
Sun Dec 18 17:49:29 EST 2005
On 12/18/05, Daniel Carrera <daniel.carrera at zmsl.com> wrote:
> Chris Kuklewicz wrote:
> > By nomad you seemed to either be ridiculing or misspelling monad.
> Misspelling. It's a new word for me. I'm not really sure what it means.
> I expect it'll take me a while to figure it out.
It sounds scary, I know!
For now I'd recommend you to just think of it as "A computation, which
may have side-effects, returning a value". And consider the
do-notation as a way to "merge multiple computations together into a
For instance, "print" is a computation taking a showable value,
returning () with the side effect that a string representation of the
value is printed to stdout.
Writing an IO program is then easily conceptualised as just "merging"
together several existing IO computations into a single one. The
compiler will take care of generating code for actually *running* the
IO computation, your job is to define it.
Monads have more uses than this, and there's a bit of interesting
things to think about when learning about them, but you should
probably hold off on that for now.
More information about the Haskell-Cafe