http://www.haskell.org/all_about_monads/html/iomonad.html Input/Output is incompatible with a pure functional language because
it is not referentially transparent and side-effect free. The IO
monad solves this problem by confining computations that perform I/O
within the IO monad.
The definition of the IO monad is platform-specific.
No data constructors are exported and no functions are provided
to remove data from the IO monad. This makes the IO monad a
one-way monad and is essential to ensuring safety of functional
programs by isolating side-effects and non-referentially transparent
actions within the imperative-style computations of the IO monad.
instance Monad IO where
return a = ... -- function from a -> IO a
m >>= k = ... -- executes the I/O action m and binds the value to k's input
fail s = ioError (userError s)
data IOError = ...
ioError :: IOError -> IO a
ioError = ...
userError :: String -> IOError
userError = ...
catch :: IO a -> (IOError -> IO a) -> IO a
catch = ...
try :: IO a -> IO (Either IOError a)
try f = catch (do r <- f
return (Right r))
(return . Left)
http://www.haskell.org/all_about_monads/html/iomonad.html