Skip to content
Snippets Groups Projects
Commit 5442b38b authored by Alexis King's avatar Alexis King
Browse files

wip: update for Outputable changes

parent 7bd04379
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ import Haddock.Utils hiding (out)
import GHC
import GHC.Driver.Ppr
import GHC.Utils.Outputable as Outputable
import GHC.Utils.Outputable as Outputable hiding (lines)
import GHC.Utils.Panic
import GHC.Unit.State
......@@ -102,21 +102,21 @@ dropComment (x:xs) = x : dropComment xs
dropComment [] = []
outWith :: Outputable a => (SDoc -> String) -> a -> [Char]
outWith :: Outputable SDoc a => (SDoc -> String) -> a -> [Char]
outWith p = f . unwords . map (dropWhile isSpace) . lines . p . ppr
where
f xs | " <document comment>" `isPrefixOf` xs = f $ drop 19 xs
f (x:xs) = x : f xs
f [] = []
out :: Outputable a => DynFlags -> a -> String
out :: Outputable SDoc a => DynFlags -> a -> String
out dflags = outWith $ showSDoc dflags
operator :: String -> String
operator (x:xs) | not (isAlphaNum x) && x `notElem` "_' ([{" = '(' : x:xs ++ ")"
operator x = x
commaSeparate :: Outputable a => DynFlags -> [a] -> String
commaSeparate :: Outputable SDoc a => DynFlags -> [a] -> String
commaSeparate dflags = showSDoc dflags . interpp'SP
---------------------------------------------------------------------
......@@ -292,17 +292,17 @@ ppFixity dflags (name, fixity) = [out dflags ((FixitySig noExtField [noLocA name
---------------------------------------------------------------------
-- DOCUMENTATION
ppDocumentation :: Outputable o => DynFlags -> Documentation o -> [String]
ppDocumentation :: Outputable SDoc o => DynFlags -> Documentation o -> [String]
ppDocumentation dflags (Documentation d w) = mdoc dflags d ++ doc dflags w
doc :: Outputable o => DynFlags -> Maybe (Doc o) -> [String]
doc :: Outputable SDoc o => DynFlags -> Maybe (Doc o) -> [String]
doc dflags = docWith dflags ""
mdoc :: Outputable o => DynFlags -> Maybe (MDoc o) -> [String]
mdoc :: Outputable SDoc o => DynFlags -> Maybe (MDoc o) -> [String]
mdoc dflags = docWith dflags "" . fmap _doc
docWith :: Outputable o => DynFlags -> String -> Maybe (Doc o) -> [String]
docWith :: Outputable SDoc o => DynFlags -> String -> Maybe (Doc o) -> [String]
docWith _ [] Nothing = []
docWith dflags header d
= ("":) $ zipWith (++) ("-- | " : repeat "-- ") $
......@@ -335,7 +335,7 @@ str a = [Str a]
-- or inlne for others (a,i,tt)
-- entities (&,>,<) should always be appropriately escaped
markupTag :: Outputable o => DynFlags -> DocMarkup o [Tag]
markupTag :: Outputable SDoc o => DynFlags -> DocMarkup o [Tag]
markupTag dflags = Markup {
markupParagraph = box TagP,
markupEmpty = str "",
......
......@@ -30,7 +30,7 @@ import Data.Maybe ( mapMaybe, fromMaybe )
import Haddock.Types( DocName, DocNameI, XRecCond )
import GHC.Utils.FV as FV
import GHC.Utils.Outputable ( Outputable )
import GHC.Utils.Outputable ( Outputable, SDoc )
import GHC.Utils.Panic ( panic )
import GHC.Driver.Ppr (showPpr )
import GHC.Types.Name
......@@ -105,7 +105,7 @@ isClassD :: HsDecl a -> Bool
isClassD (TyClD _ d) = isClassDecl d
isClassD _ = False
pretty :: Outputable a => DynFlags -> a -> String
pretty :: Outputable SDoc a => DynFlags -> a -> String
pretty = showPpr
-- ---------------------------------------------------------------------
......
{-# LANGUAGE CPP, OverloadedStrings, BangPatterns, NamedFieldPuns #-}
{-# LANGUAGE CPP, OverloadedStrings, BangPatterns, NamedFieldPuns, FlexibleContexts #-}
-----------------------------------------------------------------------------
-- |
-- Module : Haddock.Interface
......@@ -360,7 +360,7 @@ processModule1 verbosity flags ifaces inst_ifaces hsc_env mod_summary tc_gbl_env
show (srcSpanStartLine rss) ++ ")"
_ -> ""
p :: Outputable a => [a] -> String
p :: Outputable SDoc a => [a] -> String
p [] = ""
p (x:_) = let n = pretty dflags x
ms = modString ++ "."
......
......@@ -327,7 +327,7 @@ instance NamedThing DocName where
getName (Undocumented name) = name
-- | Useful for debugging
instance Outputable DocName where
instance Outputable SDoc DocName where
ppr = ppr . getName
instance OutputableBndr DocName where
......@@ -361,7 +361,7 @@ data Wrap n
deriving (Show, Functor, Foldable, Traversable)
-- | Useful for debugging
instance Outputable n => Outputable (Wrap n) where
instance Outputable SDoc n => Outputable SDoc (Wrap n) where
ppr (Unadorned n) = ppr n
ppr (Parenthesized n) = hcat [ char '(', ppr n, char ')' ]
ppr (Backticked n) = hcat [ char '`', ppr n, char '`' ]
......@@ -391,7 +391,7 @@ data InstType name
| DataInst (TyClDecl name) -- ^ Data constructors
instance (OutputableBndrId p)
=> Outputable (InstType (GhcPass p)) where
=> Outputable SDoc (InstType (GhcPass p)) where
ppr (ClassInst { .. }) = text "ClassInst"
<+> ppr clsiCtx
<+> ppr clsiTyVars
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment