[commit: haddock] master, wip/api-annots-ghc-7.10-3: Don't print instance safety information in Hoogle (e49d473)

git at git.haskell.org git at git.haskell.org
Wed Jul 8 08:38:02 UTC 2015


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

On branches: master,wip/api-annots-ghc-7.10-3
Link       : http://git.haskell.org/haddock.git/commitdiff/e49d473bf33fa374c60462ad178ac539f026c3ff

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

commit e49d473bf33fa374c60462ad178ac539f026c3ff
Author: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
Date:   Fri Mar 27 03:04:21 2015 +0000

    Don't print instance safety information in Hoogle
    
    Fixes #168


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

e49d473bf33fa374c60462ad178ac539f026c3ff
 CHANGES                                    |  2 ++
 haddock-api/src/Haddock/Backends/Hoogle.hs | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index 7aba49a..af90b4f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -41,6 +41,8 @@ Changes in version 2.16.0
 
  * Output method documentation in Hoogle backend (#259)
 
+ * Don't print instance safety information in Hoogle (#168)
+
 Changes in version 2.15.0
 
  * Always read in prologue files as UTF8 (#286 and Cabal #1721)
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs
index 12dfc1f..914e346 100644
--- a/haddock-api/src/Haddock/Backends/Hoogle.hs
+++ b/haddock-api/src/Haddock/Backends/Hoogle.hs
@@ -15,7 +15,8 @@ module Haddock.Backends.Hoogle (
     ppHoogle
   ) where
 
-
+import BasicTypes (OverlapFlag(..), OverlapMode(..))
+import InstEnv (ClsInst(..))
 import Haddock.GhcUtils
 import Haddock.Types hiding (Version)
 import Haddock.Utils hiding (out)
@@ -169,7 +170,15 @@ ppClass dflags x subdocs = out dflags x{tcdSigs=[]} :
 
 ppInstance :: DynFlags -> ClsInst -> [String]
 ppInstance dflags x =
-  [dropComment $ outWith (showSDocForUser dflags alwaysQualify) x]
+  [dropComment $ outWith (showSDocForUser dflags alwaysQualify) cls]
+  where
+    -- As per #168, we don't want safety information about the class
+    -- in Hoogle output. The easiest way to achieve this is to set the
+    -- safety information to a state where the Outputable instance
+    -- produces no output which means no overlap and unsafe (or [safe]
+    -- is generated).
+    cls = x { is_flag = OverlapFlag { overlapMode = NoOverlap mempty
+                                    , isSafeOverlap = False } }
 
 ppSynonym :: DynFlags -> TyClDecl Name -> [String]
 ppSynonym dflags x = [out dflags x]



More information about the ghc-commits mailing list