blob: a291855a4205dd36d5a7a3b020e8394a3c0f4e7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
-- | Test that a handle from 'hDuplicate' really shares the file position with
-- its parent.
import System.IO
import GHC.IO.Handle
main :: IO ()
main = do
writeFile "test" "hello\nworld\ntesting\n"
h <- openFile "test" ReadMode
h2 <- hDuplicate h
hGetLine h >>= putStrLn -- should print "hello"
hGetLine h2 >>= putStrLn -- should print "world"
hGetLine h >>= putStrLn -- should print "testing"
|