[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / cats / hcat5.hs
diff --git a/ghc/misc/examples/cats/hcat5.hs b/ghc/misc/examples/cats/hcat5.hs
new file mode 100644 (file)
index 0000000..0a7a59f
--- /dev/null
@@ -0,0 +1,19 @@
+module Main (mainPrimIO) where
+
+import PreludePrimIO
+
+mainPrimIO :: PrimIO ()
+mainPrimIO
+  = _ccall_ stg_getc (``stdin'' :: _Addr)
+                  `thenPrimIO` \ (I# ch) ->
+    if ch <# 0# then -- SIGH: ch ==# ``EOF''
+        returnPrimIO ()
+    else
+        _ccall_ stg_putc (C# (chr# ch))
+                  (``stdout'' :: _Addr)
+                            `seqPrimIO`
+        mainPrimIO
+
+-- 1,737,897 bytes/sec ( 600KB input)
+-- 1,808,993 bytes/sec ( 9.3MB input)
+-- 1,711,850 bytes/sec (25.5MB input)