MySpace
myspace music


IO MONADE STANCA



Last Updated: 12/28/2009

Send Message
Instant Message
Email to a Friend
Subscribe

Status: Single
City: CANALE di suez, Cuneo
Country: IT
Signup Date: 4/6/2006
Monday, October 19, 2009 
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

F U H / new song uploaded / new album out 2010

 
ah ok

 
Posted by F U H / new song uploaded / new album out 2010 on Friday, October 23, 2009 - 1:31 PM
[Reply to this