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))))

Performing I/O<br />

main :: IO a<br />

A program is a single I/O action<br />

Running <strong>the</strong> program performs <strong>the</strong> action<br />

Can’t do I/O from pure code.<br />

Result: clean separation of pure code from<br />

imperative code

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

Saved successfully!

Ooh no, something went wrong!