[commit: haddock] wip/orf-reboot: Get rid of erroneous DocNames for underscore when pretty-printing (f1befea)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:39:50 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branch  : wip/orf-reboot
Link       : http://git.haskell.org/haddock.git/commitdiff/f1befeaacc630ca9fa11d316b429ecae571f91ca

>---------------------------------------------------------------

commit f1befeaacc630ca9fa11d316b429ecae571f91ca
Author: Adam Gundry <adam at well-typed.com>
Date:   Tue Oct 13 18:29:19 2015 +0100

    Get rid of erroneous DocNames for underscore when pretty-printing


>---------------------------------------------------------------

f1befeaacc630ca9fa11d316b429ecae571f91ca
 haddock-api/src/Haddock/Backends/LaTeX.hs      | 7 +++++--
 haddock-api/src/Haddock/Backends/Xhtml/Decl.hs | 6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/haddock-api/src/Haddock/Backends/LaTeX.hs b/haddock-api/src/Haddock/Backends/LaTeX.hs
index 2895006..68149b4 100644
--- a/haddock-api/src/Haddock/Backends/LaTeX.hs
+++ b/haddock-api/src/Haddock/Backends/LaTeX.hs
@@ -24,9 +24,10 @@ import qualified Pretty
 import GHC
 import OccName
 import Name                 ( nameOccName )
-import RdrName              ( rdrNameOcc )
+import RdrName              ( rdrNameOcc, mkRdrUnqual )
 import FastString           ( unpackFS, unpackLitString, zString )
 import Outputable           ( panic)
+import PrelNames            ( mkUnboundName )
 
 import qualified Data.Map as Map
 import System.Directory
@@ -900,7 +901,9 @@ ppr_mono_ty ctxt_prec (HsForAllTy expl extra tvs ctxt ty) unicode
   = maybeParen ctxt_prec pREC_FUN $
     hsep [ppForAll expl tvs ctxt' unicode, ppr_mono_lty pREC_TOP ty unicode]
  where
-   anonWC = HsWildCardTy (AnonWildCard (error "ppr_mono_ty: anonWC")) -- AMG TODO is this okay?
+   anonWC :: HsType DocName
+   anonWC = HsWildCardTy (AnonWildCard (Undocumented underscore))
+   underscore = mkUnboundName (mkRdrUnqual (mkTyVarOcc "_"))
    ctxt'
      | Just loc <- extra = (++ [L loc anonWC]) `fmap` ctxt
      | otherwise         = ctxt
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
index a6e6186..f94daab 100644
--- a/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
+++ b/haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
@@ -38,7 +38,8 @@ import GHC
 import GHC.Exts
 import Name
 import BooleanFormula
-import RdrName ( rdrNameOcc )
+import RdrName ( rdrNameOcc, mkRdrUnqual )
+import PrelNames            ( mkUnboundName )
 
 ppDecl :: Bool -> LinksInfo -> LHsDecl DocName
        -> DocForDecl DocName -> [DocInstance DocName] -> [(DocName, Fixity)]
@@ -875,7 +876,8 @@ ppr_mono_ty ctxt_prec (HsForAllTy expl extra tvs ctxt ty) unicode qual
   = maybeParen ctxt_prec pREC_FUN $ ppForAllCon expl tvs ctxt' unicode qual
                                     <+> ppr_mono_lty pREC_TOP ty unicode qual
  where
-   anonWC = HsWildCardTy (AnonWildCard (error "ppr_mono_ty: anonWC")) -- AMG TODO ?
+   anonWC = HsWildCardTy (AnonWildCard (Undocumented underscore))
+   underscore = mkUnboundName (mkRdrUnqual (mkTyVarOcc "_"))
    ctxt'
      | Just loc <- extra = (++ [L loc anonWC]) `fmap` ctxt
      | otherwise         = ctxt



More information about the ghc-commits mailing list