Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Haskell for Web Developers. Parent comment
for strings:
main = repl "" repl :: String -> IO () repl a = getLine >>= \c -> print (a++c) >> repl (a++c)
main = repl 0 repl :: Int -> IO () repl a = fmap read getLine >>= \b -> print (a+b) >> repl (a+b)
repl a = do $ b <- getLine print sum repl sum where sum = a + read b
getContents >>= mapM_ print . drop 1 . scanl (+) 0 . map read . lines
for strings:
and it's not that much harder for Ints or using do notation which is still concise and easy to read.