1 module ParserCoreUtils where
5 data ParseResult a = OkP a | FailP String
6 type P a = String -> Int -> ParseResult a
8 thenP :: P a -> (a -> P b) -> P b
17 failP :: String -> P a
18 failP s s' _ = FailP (s ++ ":" ++ s')
20 getCoreModuleName :: FilePath -> IO String
21 getCoreModuleName fpath =
23 h <- openFile fpath ReadMode
25 let mo = findMod (words ls)
26 -- make sure we close up the file right away.
27 (length mo) `seq` return ()
30 (\ _ -> return "Main")
33 -- TODO: this should just return the module name, without the package name
34 findMod ("%module":m:_) = m
35 findMod (_:xs) = findMod xs