diff options
Diffstat (limited to 'src/Haddock/DocName.hs')
-rw-r--r-- | src/Haddock/DocName.hs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Haddock/DocName.hs b/src/Haddock/DocName.hs new file mode 100644 index 00000000..bb3cf711 --- /dev/null +++ b/src/Haddock/DocName.hs @@ -0,0 +1,50 @@ +-- +-- Haddock - A Haskell Documentation Tool +-- +-- (c) Simon Marlow 2003 +-- + + +module Haddock.DocName where + + +import Haddock.GHC.Utils + +import GHC +import OccName +import Name +import Binary +import Outputable + + +data DocName = Documented Name Module | Undocumented Name + + +docNameOcc :: DocName -> OccName +docNameOcc = nameOccName . docNameOrig + + +docNameOrig :: DocName -> Name +docNameOrig (Documented name _) = name +docNameOrig (Undocumented name) = name + + +instance Binary DocName where + put_ bh (Documented name mod) = do + putByte bh 0 + put_ bh name + put_ bh mod + put_ bh (Undocumented name) = do + putByte bh 1 + put_ bh name + + get bh = do + h <- getByte bh + case h of + 0 -> do + name <- get bh + mod <- get bh + return (Documented name mod) + 1 -> do + name <- get bh + return (Undocumented name) |