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
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Control structures<br />
Values of type (IO t) are first class<br />
So we can define our own “control structures”<br />
forever :: IO () -> IO ()<br />
forever a = do { a; forever a }<br />
repeatN :: Int -> IO () -> IO ()<br />
repeatN 0 a = return ()<br />
repeatN n a = do { a; repeatN (n-1) a }<br />
e.g. repeatN 10 (putChar ‘x’)