home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 2
/
DATAFILE_PDCD2.iso
/
utilities
/
_gofer
/
!Gofer
/
archives
/
Demos
/
gs
/
cat
< prev
next >
Wrap
Text File
|
1993-02-12
|
769b
|
21 lines
-- A version of the Unix utility cat coded up using the I/O facilities of
-- Gofer, with a dash of Gofer overloading to enable the use of different
-- argument forms:
--
-- Here is a simple version, not using any overloading:
-- (this version should work in Haskell)
unixCat :: [String] -> Dialogue
unixCat = foldr showFile done
where showFile name cont = readFile name abort
(\s->appendChan stdout s abort cont)
-- Now we get a little ambitious and write some Gofer-only code:
class Cat a where cat :: a -> Dialogue
instance Cat String where cat n = showFile n done
instance Cat [String] where cat = foldr showFile done
showFile name cont = readFile name abort (\s->appendChan stdout s abort cont)