2 -- The above warning supression flag is a temporary kludge.
3 -- While working on this module you are encouraged to remove it and fix
4 -- any warnings in the module. See
5 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
8 module ParserCoreUtils where
12 data ParseResult a = OkP a | FailP String
13 type P a = String -> Int -> ParseResult a
15 thenP :: P a -> (a -> P b) -> P b
16 m `thenP` k = \ s l ->
24 failP :: String -> P a
25 failP s s' _ = FailP (s ++ ":" ++ s')
27 getCoreModuleName :: FilePath -> IO String
28 getCoreModuleName fpath =
30 h <- openFile fpath ReadMode
32 let mo = findMod (words ls)
33 -- make sure we close up the file right away.
34 (length mo) `seq` return ()
37 (\ _ -> return "Main")
40 -- TODO: this should just return the module name, without the package name
41 findMod ("%module":m:_) = m
42 findMod (_:xs) = findMod xs