> == So how do I write "Hello, world"? == > > Well, the first thing you need to understand that in a > functional language like Haskell, this is a harder > question than it seems. Most of the code you will write > in Haskell is "purely functional", which means that it > returns the same thing every time it is run, and has no > side effects. Code with side effects is referred to as > "imperative", and is carefully isolated from functional > code in Haskell.
I believe this description is a bit misleading. Code written in the IO monad is purely functional just the same. Haskell knows no other code than purely functional one. In my humble opinion, it's unfortunate that many tutorials and introductionary texts leave the impression that monadic code would be something utterly different than "normal" Haskell code. I feel it intimidates the reader by making a monad appear like black magic, even though it's little more than syntactic sugar to describe implicit function arguments. If we'd have an opaque "World" type instead of the IO monad, 'putStrLn' would be: putStrLn :: String -> World -> World How is this function any different from any other function? So why should putStrLn :: String -> IO () be different from any other function? Peter _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe