[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / cats / hcat3.hs
diff --git a/ghc/misc/examples/cats/hcat3.hs b/ghc/misc/examples/cats/hcat3.hs
new file mode 100644 (file)
index 0000000..82208b9
--- /dev/null
@@ -0,0 +1,17 @@
+module Main (main) where
+
+import LibPosix
+
+main :: IO ()
+main = copy standardInput standardOutput
+ where
+  copy inn out
+   = try (readFileDescriptor inn 4096) >>=
+     either
+        (\ _ -> return ())
+        (\ s -> writeFileDescriptor out s >>
+                copy inn out)
+
+-- 124,879 bytes/sec ( 600KB input)
+-- 130,694 bytes/sec ( 9.3MB input)
+-- 127,263 bytes/sec (25.5MB input)