summaryrefslogtreecommitdiff
path: root/ghc/misc/examples/io
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/misc/examples/io')
-rw-r--r--ghc/misc/examples/io/io001/Main.hs1
-rw-r--r--ghc/misc/examples/io/io002/Main.hs12
-rw-r--r--ghc/misc/examples/io/io003/Main.hs9
-rw-r--r--ghc/misc/examples/io/io004/Main.hs3
-rw-r--r--ghc/misc/examples/io/io005/Main.hs11
-rw-r--r--ghc/misc/examples/io/io006/Main.hs6
-rw-r--r--ghc/misc/examples/io/io007/Main.hs11
-rw-r--r--ghc/misc/examples/io/io008/Main.hs21
-rw-r--r--ghc/misc/examples/io/io009/Main.hs6
-rw-r--r--ghc/misc/examples/io/io010/Main.hs20
-rw-r--r--ghc/misc/examples/io/io011/Main.hs17
-rw-r--r--ghc/misc/examples/io/io012/Main.hs17
-rw-r--r--ghc/misc/examples/io/io013/Main.hs17
-rw-r--r--ghc/misc/examples/io/io014/Main.hs22
-rw-r--r--ghc/misc/examples/io/io015/Main.hs10
-rw-r--r--ghc/misc/examples/io/io016/Main.hs21
-rw-r--r--ghc/misc/examples/io/io017/Main.hs19
-rw-r--r--ghc/misc/examples/io/io018/Main.hs25
-rw-r--r--ghc/misc/examples/io/io019/Main.hs22
-rw-r--r--ghc/misc/examples/io/io020/Main.hs13
-rw-r--r--ghc/misc/examples/io/io021/Main.hs6
21 files changed, 0 insertions, 289 deletions
diff --git a/ghc/misc/examples/io/io001/Main.hs b/ghc/misc/examples/io/io001/Main.hs
deleted file mode 100644
index 6620e3c1fe..0000000000
--- a/ghc/misc/examples/io/io001/Main.hs
+++ /dev/null
@@ -1 +0,0 @@
-main = putStr "Hello, world\n"
diff --git a/ghc/misc/examples/io/io002/Main.hs b/ghc/misc/examples/io/io002/Main.hs
deleted file mode 100644
index c9a1bcfa82..0000000000
--- a/ghc/misc/examples/io/io002/Main.hs
+++ /dev/null
@@ -1,12 +0,0 @@
-import System (getEnv)
-
-main =
- getEnv "TERM" >>= \ term ->
- putStr term >>
- putChar '\n' >>
- getEnv "One fish, two fish, red fish, blue fish" >>= \ fish ->
- putStr fish >>
- putChar '\n'
-
-
-
diff --git a/ghc/misc/examples/io/io003/Main.hs b/ghc/misc/examples/io/io003/Main.hs
deleted file mode 100644
index 93fff71be5..0000000000
--- a/ghc/misc/examples/io/io003/Main.hs
+++ /dev/null
@@ -1,9 +0,0 @@
-import System (getProgName, getArgs)
-
-main =
- getProgName >>= \ argv0 ->
- putStr argv0 >>
- getArgs >>= \ argv ->
- sequence (map (\ x -> putChar ' ' >> putStr x) argv) >>
- putChar '\n'
-
diff --git a/ghc/misc/examples/io/io004/Main.hs b/ghc/misc/examples/io/io004/Main.hs
deleted file mode 100644
index 69d2221743..0000000000
--- a/ghc/misc/examples/io/io004/Main.hs
+++ /dev/null
@@ -1,3 +0,0 @@
-import System (exitWith, ExitCode(..))
-
-main = exitWith (ExitFailure 42)
diff --git a/ghc/misc/examples/io/io005/Main.hs b/ghc/misc/examples/io/io005/Main.hs
deleted file mode 100644
index 3a41560df6..0000000000
--- a/ghc/misc/examples/io/io005/Main.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-import System (system, ExitCode(..), exitWith)
-
-main =
- system "cat dog 1>/dev/null 2>&1" >>= \ ec ->
- case ec of
- ExitSuccess -> putStr "What?!?\n" >> fail (userError "dog succeeded")
- ExitFailure _ ->
- system "cat Main.hs 2>/dev/null" >>= \ ec ->
- case ec of
- ExitSuccess -> exitWith ExitSuccess
- ExitFailure _ -> putStr "What?!?\n" >> fail (userError "cat failed")
diff --git a/ghc/misc/examples/io/io006/Main.hs b/ghc/misc/examples/io/io006/Main.hs
deleted file mode 100644
index 6eb862c3da..0000000000
--- a/ghc/misc/examples/io/io006/Main.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-import IO -- 1.3
-
-main =
- hClose stderr >>
- hPutStr stderr "junk" `catch` \ err -> if isIllegalOperation err then putStr "Okay\n" else error "Not okay\n"
-
diff --git a/ghc/misc/examples/io/io007/Main.hs b/ghc/misc/examples/io/io007/Main.hs
deleted file mode 100644
index 467382ff76..0000000000
--- a/ghc/misc/examples/io/io007/Main.hs
+++ /dev/null
@@ -1,11 +0,0 @@
-import IO -- 1.3
-
-main =
- openFile "io007.in" ReadMode >>= \ hIn ->
- hPutStr hIn "test" `catch`
- \ err ->
- if isIllegalOperation err then
- hGetContents hIn >>= \ stuff ->
- hPutStr stdout stuff
- else
- error "Oh dear\n"
diff --git a/ghc/misc/examples/io/io008/Main.hs b/ghc/misc/examples/io/io008/Main.hs
deleted file mode 100644
index 47f1a6ea97..0000000000
--- a/ghc/misc/examples/io/io008/Main.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-import IO -- 1.3
-import GHCio
-
-import Directory (removeFile)
-
-main =
- openFile "io008.in" ReadMode >>= \ hIn ->
- openFile "io008.out" ReadWriteMode >>= \ hOut ->
- removeFile "io008.out" >>
- hGetPosn hIn >>= \ bof ->
- copy hIn hOut >>
- hSetPosn bof >>
- copy hIn hOut >>
- hSeek hOut AbsoluteSeek 0 >>
- hGetContents hOut >>= \ stuff ->
- putStr stuff
-
-copy :: Handle -> Handle -> IO ()
-copy hIn hOut =
- tryIO (hGetChar hIn) >>=
- either (\ err -> if isEOFError err then return () else error "copy") ( \ x -> hPutChar hOut x >> copy hIn hOut)
diff --git a/ghc/misc/examples/io/io009/Main.hs b/ghc/misc/examples/io/io009/Main.hs
deleted file mode 100644
index 5f95ce0c42..0000000000
--- a/ghc/misc/examples/io/io009/Main.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-import Directory (getDirectoryContents)
-import QSort (sort)
-
-main =
- getDirectoryContents "." >>= \ names ->
- print (sort names)
diff --git a/ghc/misc/examples/io/io010/Main.hs b/ghc/misc/examples/io/io010/Main.hs
deleted file mode 100644
index 764290c754..0000000000
--- a/ghc/misc/examples/io/io010/Main.hs
+++ /dev/null
@@ -1,20 +0,0 @@
-import LibDirectory (getCurrentDirectory, setCurrentDirectory,
- createDirectory, removeDirectory, getDirectoryContents)
-
-main =
- getCurrentDirectory >>= \ oldpwd ->
- createDirectory "foo" >>
- setCurrentDirectory "foo" >>
- getDirectoryContents "." >>= \ [n1, n2] ->
- if dot n1 && dot n2 then
- setCurrentDirectory oldpwd >>
- removeDirectory "foo" >>
- putStr "Okay\n"
- else
- fail "Oops"
-
-
-dot :: String -> Bool
-dot "." = True
-dot ".." = True
-dot _ = False
diff --git a/ghc/misc/examples/io/io011/Main.hs b/ghc/misc/examples/io/io011/Main.hs
deleted file mode 100644
index 97f7d90e58..0000000000
--- a/ghc/misc/examples/io/io011/Main.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-import IO -- 1.3
-
-import Directory
-
-main =
- createDirectory "foo" >>
- openFile "foo/bar" WriteMode >>= \ h ->
- hPutStr h "Okay\n" >>
- hClose h >>
- renameFile "foo/bar" "foo/baz" >>
- renameDirectory "foo" "bar" >>
- openFile "bar/baz" ReadMode >>= \ h ->
- hGetContents h >>= \ stuff ->
- putStr stuff >>
- hClose h >>
- removeFile "bar/baz" >>
- removeDirectory "bar"
diff --git a/ghc/misc/examples/io/io012/Main.hs b/ghc/misc/examples/io/io012/Main.hs
deleted file mode 100644
index c5a16b730a..0000000000
--- a/ghc/misc/examples/io/io012/Main.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-import IO -- 1.3
-
-import CPUTime
-
-main =
- openFile "/dev/null" WriteMode >>= \ h ->
- hPrint h (nfib 30) >>
- getCPUTime >>= \ t ->
- print t
-
-nfib :: Integer -> Integer
-nfib n
- | n <= 1 = 1
- | otherwise = (n1 + n2 + 1)
- where
- n1 = nfib (n-1)
- n2 = nfib (n-2)
diff --git a/ghc/misc/examples/io/io013/Main.hs b/ghc/misc/examples/io/io013/Main.hs
deleted file mode 100644
index 9598e04d61..0000000000
--- a/ghc/misc/examples/io/io013/Main.hs
+++ /dev/null
@@ -1,17 +0,0 @@
-import IO -- 1.3
-
-main =
- openFile "io013.in" ReadMode >>= \ h ->
- hFileSize h >>= \ sz ->
- print sz >>
- hSeek h SeekFromEnd (-3) >>
- hGetChar h >>= \ x ->
- putStr (x:"\n") >>
- hSeek h RelativeSeek (-2) >>
- hGetChar h >>= \ w ->
- putStr (w:"\n") >>
- hIsSeekable h >>= \ True ->
- hClose h >>
- openFile "/dev/null" ReadMode >>= \ h ->
- hIsSeekable h >>= \ False ->
- hClose h
diff --git a/ghc/misc/examples/io/io014/Main.hs b/ghc/misc/examples/io/io014/Main.hs
deleted file mode 100644
index fecf4a51d7..0000000000
--- a/ghc/misc/examples/io/io014/Main.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-import IO -- 1.3
-
-main =
- accumulate (map hIsOpen [stdin, stdout, stderr]) >>= \ opens ->
- print opens >>
- accumulate (map hIsClosed [stdin, stdout, stderr]) >>= \ closeds ->
- print closeds >>
- accumulate (map hIsReadable [stdin, stdout, stderr]) >>= \ readables ->
- print readables >>
- accumulate (map hIsWritable [stdin, stdout, stderr]) >>= \ writables ->
- print writables >>
- accumulate (map hIsBlockBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
- print buffereds >>
- accumulate (map hIsLineBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
- print buffereds >>
- accumulate (map hIsNotBuffered [stdin, stdout, stderr]) >>= \ buffereds ->
- print buffereds
- where
- -- these didn't make it into 1.3
- hIsBlockBuffered h = hGetBuffering h >>= \ b -> return $ case b of { BlockBuffering _ -> True; _ -> False }
- hIsLineBuffered h = hGetBuffering h >>= \ b -> return $ case b of { LineBuffering -> True; _ -> False }
- hIsNotBuffered h = hGetBuffering h >>= \ b -> return $ case b of { NoBuffering -> True; _ -> False }
diff --git a/ghc/misc/examples/io/io015/Main.hs b/ghc/misc/examples/io/io015/Main.hs
deleted file mode 100644
index 37f0cc134a..0000000000
--- a/ghc/misc/examples/io/io015/Main.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-import IO -- 1.3
-
-main =
- isEOF >>= \ eof ->
- if eof then
- return ()
- else
- getChar >>= \ c ->
- putChar c >>
- main
diff --git a/ghc/misc/examples/io/io016/Main.hs b/ghc/misc/examples/io/io016/Main.hs
deleted file mode 100644
index 1ce01b2d45..0000000000
--- a/ghc/misc/examples/io/io016/Main.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-import IO -- 1.3
-
-import System (getArgs)
-import Char (toUpper)
-
-main = getArgs >>= \ [f1,f2] ->
- openFile f1 ReadMode >>= \ h1 ->
- openFile f2 WriteMode >>= \ h2 ->
- copyFile h1 h2 >>
- hClose h1 >>
- hClose h2
-
-copyFile h1 h2 =
- hIsEOF h1 >>= \ eof ->
- if eof then
- return ()
- else
- hGetChar h1 >>= \ c ->
- hPutChar h2 (toUpper c) >>
- copyFile h1 h2
-
diff --git a/ghc/misc/examples/io/io017/Main.hs b/ghc/misc/examples/io/io017/Main.hs
deleted file mode 100644
index 2be725480b..0000000000
--- a/ghc/misc/examples/io/io017/Main.hs
+++ /dev/null
@@ -1,19 +0,0 @@
-import IO -- 1.3
-
-main =
- hSetBuffering stdout NoBuffering >>
- putStr "Enter an integer: " >>
- readLine >>= \ x1 ->
- putStr "Enter another integer: " >>
- readLine >>= \ x2 ->
- putStr ("Their sum is " ++ show (read x1+ read x2) ++ "\n")
-
- where readLine = isEOF >>= \ eof ->
- if eof then return []
- else getChar >>= \ c ->
- if c `elem` ['\n','\r'] then
- return []
- else
- readLine >>= \ cs ->
- return (c:cs)
-
diff --git a/ghc/misc/examples/io/io018/Main.hs b/ghc/misc/examples/io/io018/Main.hs
deleted file mode 100644
index 7318cc7ac9..0000000000
--- a/ghc/misc/examples/io/io018/Main.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-import IO -- 1.3
-
-import System(getArgs)
-
-main = getArgs >>= \ [user,host] ->
- let username = (user ++ "@" ++ host) in
- openFile username ReadWriteMode >>= \ cd ->
- hSetBuffering stdin NoBuffering >>
- hSetBuffering stdout NoBuffering >>
- hSetBuffering cd NoBuffering >>
- hPutStr cd speakString >>
- speak cd
-
-speakString = "Someone wants to speak with you\n"
-
-speak cd =
- (hReady cd >>= \ ready ->
- if ready then (hGetChar cd >>= putChar)
- else return () >>
-
- hReady stdin >>= \ ready ->
- if ready then (getChar >>= hPutChar cd)
- else return ()) >>
-
- speak cd
diff --git a/ghc/misc/examples/io/io019/Main.hs b/ghc/misc/examples/io/io019/Main.hs
deleted file mode 100644
index bd50838bb5..0000000000
--- a/ghc/misc/examples/io/io019/Main.hs
+++ /dev/null
@@ -1,22 +0,0 @@
-import Time
-
-main =
- getClockTime >>= \ time ->
- print time >>
-
- let (CalendarTime year month mday hour min sec psec
- wday yday timezone gmtoff isdst) = toUTCTime time
- in
- putStr (wdays !! wday) >>
- putStr (' ' : months !! month) >>
- putStr (' ' : shows2 mday (' ' : shows2 hour (':' : shows2 min (':' : shows2 sec
- (' ' : timezone ++ ' ' : shows year "\n")))))
-
- where
- wdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
- months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
- shows2 x = showString (pad2 x)
- pad2 x = case show x of
- c@[_] -> '0' : c
- cs -> cs
diff --git a/ghc/misc/examples/io/io020/Main.hs b/ghc/misc/examples/io/io020/Main.hs
deleted file mode 100644
index 1f349ebd32..0000000000
--- a/ghc/misc/examples/io/io020/Main.hs
+++ /dev/null
@@ -1,13 +0,0 @@
-import Time
-
-main =
- getClockTime >>= \ time ->
- let (CalendarTime year month mday hour min sec psec
- wday yday timezone gmtoff isdst) = toUTCTime time
- time' = toClockTime (CalendarTime (year - 1) month mday hour min sec psec
- wday yday timezone gmtoff isdst)
- in
- print time >>
- putChar '\n' >>
- print time' >>
- putChar '\n'
diff --git a/ghc/misc/examples/io/io021/Main.hs b/ghc/misc/examples/io/io021/Main.hs
deleted file mode 100644
index c45a40b9b1..0000000000
--- a/ghc/misc/examples/io/io021/Main.hs
+++ /dev/null
@@ -1,6 +0,0 @@
-import IO -- 1.3
-
-main =
- hSetBuffering stdin NoBuffering >>
- hSetBuffering stdout NoBuffering >>
- interact id