1 {- A simple driver that loads, typechecks, prepares, re-typechecks, and interprets the
2 GHC standard Prelude modules and an application module called Main.
4 Note that, if compiled under GHC, this requires a very large heap to run!
8 import System.Environment
21 process (senv,modules) f =
22 do putStrLn ("Processing " ++ f)
25 OkP m -> do putStrLn "Parse succeeded"
26 {- writeFile (f ++ ".parsed") (show m) -}
27 case checkModule senv m of
29 do putStrLn "Check succeeded"
30 let m' = prepModule senv' m
31 {- writeFile (f ++ ".prepped") (show m') -}
32 case checkModule senv m' of
34 do putStrLn "Recheck succeeded"
35 return (senv'',modules ++ [m'])
37 do putStrLn ("Recheck failed: " ++ s)
40 do putStrLn ("Check failed: " ++ s)
42 FailP s -> do putStrLn ("Parse failed: " ++ s)
45 main = do fname <- getSingleArg
46 (_,modules) <- foldM process (initialEnv,[]) [fname] -- flist
47 let result = evalProgram modules
48 putStrLn ("Result = " ++ show result)
52 where flist = ["Main.hcr"]
53 getSingleArg = getArgs >>= (\ a ->
56 _ -> error $ "usage: ./Driver [filename]")
86 "PrelMarshalAlloc.hcr",
87 "PrelMarshalUtils.hcr",
88 "PrelMarshalArray.hcr",
90 "PrelMarshalError.hcr",