Make haddock happy

This commit is contained in:
Don Stewart
2005-09-03 03:37:58 +00:00
parent 1191f0595e
commit b4529492d9
5 changed files with 78 additions and 76 deletions

View File

@ -1,6 +1,6 @@
{-# OPTIONS -cpp -fglasgow-exts #-}
{-# OPTIONS -fglasgow-exts #-}
--
-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons
-- Copyright (C) 2004-5 Don Stewart - http://www.cse.unsw.edu.au/~dons
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
@ -67,24 +67,23 @@ pretty :: HsModule -> String
pretty code = prettyPrintWithMode (defaultMode { linePragmas = True }) code
-- |
-- mergeModules : generate a full Haskell src file, give a .hs config
-- | mergeModules : generate a full Haskell src file, give a .hs config
-- file, and a stub to take default syntax and decls from. Mostly we
-- just ensure they don't do anything bad, and that the names are
-- correct for the module.
--
-- Transformations:
-- Transformations:
--
-- * Take src location pragmas from the conf file (1st file)
-- * Use the template's (2nd argument) module name
-- * Only use export list from template (2nd arg)
-- * Merge top-level decls
-- * need to force the type of the plugin to match the stub,
-- . Take src location pragmas from the conf file (1st file)
-- . Use the template's (2nd argument) module name
-- . Only use export list from template (2nd arg)
-- . Merge top-level decls
-- . need to force the type of the plugin to match the stub,
-- overwriting any type they supply.
--
mergeModules :: HsModule -> -- ^ Configure module
HsModule -> -- ^ Template module
HsModule -- ^ A merge of the two
mergeModules :: HsModule -> -- Configure module
HsModule -> -- Template module
HsModule -- A merge of the two
mergeModules (HsModule l _ _ is ds )
(HsModule _ m' es' is' ds')
@ -93,7 +92,7 @@ mergeModules (HsModule l _ _ is ds )
(mDecl ds ds') )
--
-- replace Module name with String.
-- | replace Module name with String.
--
replaceModName :: HsModule -> String -> HsModule
replaceModName (HsModule l _ es is ds) nm = (HsModule l (Module nm) es is ds)
@ -104,15 +103,15 @@ replaceModName (HsModule l _ es is ds) nm = (HsModule l (Module nm) es is ds)
-- * ensure that the config file doesn't import the stub name
-- * merge import lists uniquely, and when they match, merge their decls
--
-- TODO : we don't merge imports of the same module from both files.
-- TODO * we don't merge imports of the same module from both files.
-- We should, and then merge the decls in their import list
-- ** rename args, too confusing.
-- * rename args, too confusing.
--
-- quick fix: strip all type signatures from the source.
--
mImps :: Module -> -- ^ plugin module name
[HsImportDecl] -> -- ^ conf file imports
[HsImportDecl] -> -- ^ stub file imports
mImps :: Module -> -- plugin module name
[HsImportDecl] -> -- conf file imports
[HsImportDecl] -> -- stub file imports
[HsImportDecl]
mImps plug_mod cimps timps =
@ -126,11 +125,10 @@ mImps plug_mod cimps timps =
-- Remove decls found in template, using those from the config file.
-- Need to sort decls by types, then decls first, in both.
--
-- * could we write a pass to handle "editor, foo :: String" ?
-- Could we write a pass to handle editor, foo :: String ?
-- We must keep the type from the template.
--
-- we must keep the type from the template.
--
mDecl ds es = let ds' = filter (\t->not $ typeDecl t) ds -- rm type sigs from plugin
mDecl ds es = let ds' = filter (not.typeDecl) ds
in sortBy decls $! unionBy (=~) ds' es
where
decls a b = compare (encoding a) (encoding b)
@ -167,16 +165,17 @@ instance SynEq HsImportDecl where
-- | Parsing option pragmas.
--
-- This is not a type checker. If the user supplies bogus options,
-- they'll get slightly mystical error messages. Also, we *want* to
-- handle -package options, and other *static* flags. This is more than
-- they'll get slightly mystical error messages. Also, we /want/ to
-- handle -package options, and other /static/ flags. This is more than
-- GHC.
--
-- GHC user's guide :
-- "OPTIONS pragmas are only looked for at the top of your source
-- files, upto the first (non-literate,non-empty) line not
-- containing OPTIONS. Multiple OPTIONS pragmas are recognised."
--
-- based on getOptionsFromSource(), in main/DriverUtil.hs
-- > OPTIONS pragmas are only looked for at the top of your source
-- > files, up to the first (non-literate,non-empty) line not
-- > containing OPTIONS. Multiple OPTIONS pragmas are recognised.
--
-- based on getOptionsFromSource(), in main\/DriverUtil.hs
--
parsePragmas :: String -- ^ input src
-> ([String],[String]) -- ^ normal options, global options
@ -197,7 +196,7 @@ parsePragmas s = look $ lines s
| otherwise -> ([],[])
--
-- based on main/DriverUtil.hs
-- based on main\/DriverUtil.hs
--
-- extended to handle dynamic options too
--
@ -223,7 +222,7 @@ remove_spaces :: String -> String
remove_spaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
--
-- verbatim from utils/Utils.lhs
-- verbatim from utils\/Utils.lhs
--
prefixMatch :: Eq a => [a] -> [a] -> Bool
prefixMatch [] _str = True