1 module ParserCoreUtils where
6 data ParseResult a = OkP a | FailP String
7 type P a = String -> Int -> ParseResult a
9 thenP :: P a -> (a -> P b) -> P b
10 m `thenP` k = \ s l ->
18 failP :: String -> P a
19 failP s s' _ = FailP (s ++ ":" ++ s')
21 getCoreModuleName :: FilePath -> IO String
22 getCoreModuleName fpath =
24 h <- openFile fpath ReadMode
26 let mo = findMod (words ls)
27 -- make sure we close up the file right away.
28 (length mo) `seq` return ()
31 (\ _ -> return "Main")
34 -- TODO: this should just return the module name, without the package name
35 findMod ("%module":m:_) = m
36 findMod (_:xs) = findMod xs