Wearing the hair shirt Wearing the hair shirt - Microsoft Research

Wearing the hair shirt Wearing the hair shirt - Microsoft Research Wearing the hair shirt Wearing the hair shirt - Microsoft Research

research.microsoft.com
from research.microsoft.com More from this publisher
27.12.2013 Views

Performing I/O main :: IO a A program is a single I/O action Running the program performs the action Can’t do I/O from pure code. Result: clean separation of pure code from imperative code

Connecting I/O operations (>>=) :: IO a -> (a -> IO b) -> IO b return :: a -> IO a eg. getChar >>= (\a -> getChar >>= (\b -> putChar b >>= (\() -> return (a,b))))

Connecting I/O operations<br />

(>>=) :: IO a -> (a -> IO b) -> IO b<br />

return :: a -> IO a<br />

eg.<br />

getChar >>= (\a -><br />

getChar >>= (\b -><br />

putChar b >>= (\() -><br />

return (a,b))))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!