595b86b2722b9eac5b617c71dfd4b9e8ee8a8cd6
[ghc-hetmet.git] / ghc / tests / programs / jeff-bug / HawkIO.hs
1 module HawkIO
2   (
3          hawkMain
4   ) where
5
6 import IO
7 import Memory
8
9 -- Begin Signature ------------------------------------------------------
10 {-
11 Given a filename, and function from a memory state and a starting point to a 
12 an output, "hawkMain" will open the file and parse it and apply the
13 function to it.
14 -}
15
16
17 hawkMain :: (Read a,Read w) => String -> ((MemoryState w a,w) -> IO b) -> IO b
18 -- End Signature ------------------------------------------------------
19
20
21 hawkMain filename f = do {ps <- readInitFile filename; f ps}
22
23
24 readInitFile :: (Read a,Read w) => String -> IO (MemoryState w a,w)
25 readInitFile infile =
26  do{ h <- openFile infile ReadMode
27    ; s <- hGetContents h
28    ; return (read s)
29    }