aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/DocName.hs
blob: 66170d8c8f7ccee7488d8e2f024627f5f1e7a950 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--
-- Haddock - A Haskell Documentation Tool
--
-- (c) Simon Marlow 2003
--


{-# OPTIONS_HADDOCK hide #-}


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)