{-
   ErrorInGraph.lhs

   The following happens when running this program 
   and data file does not exist:

Main> main
Reading: C:\Mijn documenten\beleggen\koersen\TestSet3\040814\lnk00000.dat
Program error:
Program error: pattern match failure
(637 reductions, 1460 cells, 1 garbage collection)
INTERNAL ERROR: Error in graph
Main> main
Reading: C:\Mijn documenten\beleggen\koersen\TestSet3\040814\lnk00000.dat

Program error: C:\Mijn documenten\beleggen\koersen\TestSet3\040814\lnk00000.dat:
 IO.openFile: does not exist (file does not exist)

   2004-09-29

   History:
   04....  ...
-}

> import IO
> import Monad
> import DeepSeq

===============================================================================
main
===============================================================================

> main :: IO ()
> main = 
>   do 
>     hInputSet   <- openFile "filenames.dat" ReadMode
>     fileNames   <- hGetContents hInputSet
>     -- fileNames   <- return "x\\x.x"

>     x <- liftM (unlines .
>                 concat) $
>       mapM collectData  $
>       lines fileNames  
>
>     putStr x
>            
>     hClose hInputSet

===============================================================================
collectData 
Read the first line of a file
===============================================================================

> collectData :: String ->      -- A filename
>                IO [String]    -- A list of results
> 
> collectData []       = return []
> collectData fileName = 
>   do
>     h <- openFile fileName ReadMode
> 
>     contents  <- hGetContents h
>     firstLine <- return $!! head $ lines contents
>     hClose h
>
>     return [fileName, firstLine, ""]

