[Haskell-cafe] IO is a bad example for Monads
daniel.is.fischer at web.de
Sun Dec 9 18:35:29 EST 2007
Am Sonntag, 9. Dezember 2007 23:35 schrieb Ketil Malde:
> Daniel Fischer <daniel.is.fischer at web.de> writes:
> >>> 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.
> > 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.
Emphasis on *use*, introduce the concept of monads not before lists, Maybe and
> Well, I guess you could get pretty far using 'interact' - far enough
> in an educational setting to do lists and Maybe, and then monads,
> before introducing monadic IO.
Pretty far, yes, and in an educational setting, at a university, it is quite
common, I believe, to use an interpreter for a while, not producing
executables (that's how I met Haskell, write pure functions and type
expressions at the Hugs prompt). But what about a tutorial for programmers?
How would you do
main = do
putStrLn "Please enter your name."
name <- getLine
putStrLn $ "Hello " ++ name ++ ", nice to meet you."
in that setting?
I doubt you could keep many interested without telling them how to create
standalone programmes, including reading input from stdin and printing output
More information about the Haskell-Cafe