diff options
author | simonmar <unknown> | 2002-06-21 15:50:42 +0000 |
---|---|---|
committer | simonmar <unknown> | 2002-06-21 15:50:42 +0000 |
commit | 4831dbbdd3d9899efdd07093507ae7bf08209289 (patch) | |
tree | 67dd8f744befe07ed9c6e7471e272faa991bf40c /src/HaddockUtil.hs | |
parent | b8dbfe209d85d26d4b89d9d47b7d0604f6e05c46 (diff) |
[haddock @ 2002-06-21 15:50:42 by simonmar]
Add support for reading and writing interface files(!)
This turned out to be quite easy, and necessary to get decent
hyperlinks between the documentation for separate packages in the
libraries.
The functionality isn't quite complete yet: for a given package of
modules, you'd like to say "the HTML for these modules lives in
directory <dir>" (currently they are assumed to be all in the same
place).
Two new flags:
--dump-interface=FILE dump an interface file in FILE
--read-interface=FILE read interface from FILE
an interface file describes *all* the modules being processed. Only
the exported names are kept in the interface: if you re-export a name
from a module in another interface the signature won't be copied.
This is a compromise to keep the size of the interfaces sensible.
Also, I added another useful option:
--no-implicit-prelude
avoids trying to import the Prelude. Previously this was the default,
but now importing the Prelude from elsewhere makes sense if you also
read in an interface containing the Prelude module, so Haddock imports
the Prelude implicitly according to the Haskell spec.
Diffstat (limited to 'src/HaddockUtil.hs')
-rw-r--r-- | src/HaddockUtil.hs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/HaddockUtil.hs b/src/HaddockUtil.hs index b0ad3544..27a83770 100644 --- a/src/HaddockUtil.hs +++ b/src/HaddockUtil.hs @@ -26,6 +26,8 @@ import List ( intersect ) import IO ( hPutStr, stderr ) import System import RegexString +import Binary +import IOExts -- ----------------------------------------------------------------------------- -- Some Utilities @@ -220,3 +222,36 @@ mapMaybeM :: Monad m => (a -> m b) -> Maybe a -> m (Maybe b) mapMaybeM f Nothing = return Nothing mapMaybeM f (Just a) = f a >>= return . Just +----------------------------------------------------------------------------- +-- Binary instances for stuff + +instance Binary Module where + put_ bh (Module m) = putString bh m + get bh = do m <- getString bh; return $! (Module m) + +instance Binary HsQName where + put_ bh (Qual m s) = do putByte bh 0; put_ bh m; put_ bh s + put_ bh (UnQual s) = do putByte bh 1; put_ bh s + get bh = do b <- getByte bh + case b of + 0 -> do m <- get bh; s <- get bh; return (Qual m s) + _ -> do s <- get bh; return (UnQual s) + +instance Binary HsName where + put_ bh (HsTyClsName s) = do putByte bh 0; put_ bh s + put_ bh (HsVarName s) = do putByte bh 1; put_ bh s + get bh = do b <- getByte bh + case b of + 0 -> do s <- get bh; return (HsTyClsName s) + _ -> do s <- get bh; return (HsVarName s) + +instance Binary HsIdentifier where + put_ bh (HsIdent s) = do putByte bh 0; putString bh s + put_ bh (HsSymbol s) = do putByte bh 1; putString bh s + put_ bh (HsSpecial s) = do putByte bh 2; putString bh s + get bh = do b <- getByte bh + case b of + 0 -> do s <- getString bh; return (HsIdent s) + 1 -> do s <- getString bh; return (HsSymbol s) + _ -> do s <- getString bh; return (HsSpecial s) + |