[Haskell-cafe] IO is a bad example for Monads [was: do]
Daniel Fischer
daniel.is.fischer at web.de
Sun Dec 9 13:07:17 EST 2007
Am Sonntag, 9. Dezember 2007 18:31 schrieb Conal Elliott:
> > IO is important because you can't write any real program without using
> > it.
>
> Ouch! I get awfully discouraged when I read statements like this one. The
> more people who believe it, the more true it becomes. If you want to do
> functional programming, instead of imperative programming in a functional
> language, you can. For instance, write real, interactive programs in FRP,
> phooey, or TV. And if you do, you'll get semantic simplicity, powerful &
> simpler reasoning, safety and composability.
>
> - Conal
>
Interactive programmes without using IO? Cool :)
I think you misunderstood Lennart.
Would you deny that any useful programme has to do at least some of the
following:
-accept programme arguments at invocation
-get input, be it from a keyboard, mouse, reading files, pipes...
-output a result or state info, to the monitor, a file, a pipe...
I think Lennart was referring to that, you HAVE to know a little IO to write
programmes, at least getArgs, getLine, putStr(Ln), readFile, writeFile,
appendFile. And therefore some use of the IO monad has to be taught
relatively early.
Another thing is that you should use IO only where it's necessary, which is
admittedly rare.
Cheers,
Daniel
More information about the Haskell-Cafe
mailing list