
29 Aug
2012
29 Aug
'12
5:04 a.m.
On Wed, Aug 29, 2012 at 10:58 AM, Corentin Dupont
Hi all, there is something very basic that it seems escaped me. For example with the following program f and g have type IO () and I can thread a value between the two using a file. Can I do the exact same (not changing the types of f and g) without a file?
f,g :: IO () f = withFile "toto" WriteMode (flip hPutStr "toto") g = withFile "toto" ReadMode hGetLine >>= putStrLn main = f >> g
Of course: f,g :: IO () f = putStr "Answer: " g = print 42 Main> f >> g Answer: 42 The () is threaded by >>, not the file content -- MM