home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / gofer230.zip / Progs / Gofer / Demos / cat.gs < prev    next >
Text File  |  1994-06-23  |  769b  |  21 lines

  1. -- A version of the Unix utility cat coded up using the I/O facilities of
  2. -- Gofer, with a dash of Gofer overloading to enable the use of different
  3. -- argument forms:
  4. --
  5.  
  6. -- Here is a simple version, not using any overloading:
  7. -- (this version should work in Haskell)
  8.  
  9. unixCat :: [String] -> Dialogue
  10. unixCat  = foldr showFile done
  11.            where showFile name cont = readFile name abort
  12.                                       (\s->appendChan stdout s abort cont)
  13.  
  14. -- Now we get a little ambitious and write some Gofer-only code:
  15.  
  16. class    Cat a        where cat  :: a -> Dialogue
  17. instance Cat String   where cat n = showFile n done
  18. instance Cat [String] where cat   = foldr showFile done
  19.  
  20. showFile name cont = readFile name abort (\s->appendChan stdout s abort cont)
  21.