google: "What the hell are Monads"
http://www.abercrombiegroup.co.uk/~noel/research/monads.html

IO in haskell is really easy, iff you understand the sense of monads.

to understand sth. like "IO Bool" you have to remember that i.e. an array is no 
defined data type without the definition of its entries.
"[Bool]" is sth. like that, too. the data type does not contain one "[]" and one 
"Bool".

"IO a" is in fact an Input-Output-operation with return type "a".
imagine this:
"State -> (State,a)" the world state changes and there is an "a" as result part. it is 
not possible (mathematical, not technical) to throw away the fact that it is a 
function changing the state.

your main function is of type...

main :: IO ()

where "()" means sth. like "void".
the IOs have just to be concatenated to construct a program.

main :: IO ()
main = putStr "Hello "
       >> return "world!"
       >>= putStrLn
       >> getChar
       >>= (\c -> putStrLn [c,c,c])
       >> return ()

you have to write a line and press <Return>, then getChar reads the first Char of your 
line.


_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to