[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / cats / hcat4.hs
diff --git a/ghc/misc/examples/cats/hcat4.hs b/ghc/misc/examples/cats/hcat4.hs
new file mode 100644 (file)
index 0000000..d4e6ce3
--- /dev/null
@@ -0,0 +1,20 @@
+module Main (mainPrimIO) where
+
+import PreludePrimIO
+
+mainPrimIO :: PrimIO ()
+mainPrimIO
+ = copy (``stdin'' :: _FILE)
+        (``stdout'' :: _FILE)
+ where
+  copy inn out
+   = fread 1 4096 inn
+         `thenPrimIO` \ (n, s) ->
+     if n <= 0
+     then returnPrimIO ()
+     else fwrite s 1 n out `seqPrimIO`
+          copy inn out
+
+-- 4,170,953 bytes/sec ( 600KB input)
+-- 7,993,583 bytes/sec ( 9.3MB input)
+-- 6,917,175 bytes/sec (25.5MB input)