summaryrefslogtreecommitdiff
path: root/ghc/misc/examples/cats/hcat4.hs
blob: d4e6ce36111d3639fb8f471230a98f6139b12f53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)