From ac5ec36f9eb9b697be6f4ceb63041a0abdcfd6d0 Mon Sep 17 00:00:00 2001 From: Fendor Date: Wed, 3 Feb 2021 19:10:20 +0100 Subject: Add UnitId to Target record --- haddock-api/src/Haddock/Interface.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface.hs b/haddock-api/src/Haddock/Interface.hs index 16643d0e..7cc76953 100644 --- a/haddock-api/src/Haddock/Interface.hs +++ b/haddock-api/src/Haddock/Interface.hs @@ -157,7 +157,7 @@ createIfaces verbosity modules flags instIfaceMap = do -- alive to be able to find all the instances. modifySession installHaddockPlugin - targets <- mapM (\filePath -> guessTarget filePath Nothing) modules + targets <- mapM (\filePath -> guessTarget filePath Nothing Nothing) modules setTargets targets loadOk <- withTimingM "load" (const ()) $ -- cgit v1.2.3 From cf7d06b8ac0f47d6ff1c2d3decdb6a50a0fd7502 Mon Sep 17 00:00:00 2001 From: alexbiehl Date: Tue, 9 Feb 2021 12:42:30 +0100 Subject: Stable sort for (data/newtype) instances --- .../src/Haddock/Interface/AttachInstances.hs | 25 +- html-test/ref/Bug1004.html | 1064 ++++++++++---------- html-test/ref/Bug1103.html | 8 +- html-test/ref/Bug548.html | 96 +- html-test/ref/HiddenInstances.html | 8 +- html-test/ref/Instances.html | 354 +++---- html-test/ref/SpuriousSuperclassConstraints.html | 108 +- html-test/ref/TypeFamilies.html | 196 ++-- html-test/ref/TypeFamilies2.html | 68 +- html-test/ref/TypeFamilies3.html | 64 +- hypsrc-test/ref/src/Classes.html | 14 +- hypsrc-test/ref/src/Records.html | 16 +- latex-test/ref/TypeFamilies3/TypeFamilies3.tex | 4 +- 13 files changed, 1017 insertions(+), 1008 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface/AttachInstances.hs b/haddock-api/src/Haddock/Interface/AttachInstances.hs index 6ef0ed19..d5b80888 100644 --- a/haddock-api/src/Haddock/Interface/AttachInstances.hs +++ b/haddock-api/src/Haddock/Interface/AttachInstances.hs @@ -179,19 +179,28 @@ findFixity iface ifaceMap instIfaceMap = \name -> -- Collecting and sorting instances -------------------------------------------------------------------------------- +-- | Stable name for stable comparisons. GHC's `Name` uses unstable +-- ordering based on their `Unique`'s. +newtype SName = SName Name + +instance Eq SName where + SName n1 == SName n2 = n1 `stableNameCmp` n2 == EQ + +instance Ord SName where + SName n1 `compare` SName n2 = n1 `stableNameCmp` n2 -- | Simplified type for sorting types, ignoring qualification (not visible -- in Haddock output) and unifying special tycons with normal ones. -- For the benefit of the user (looks nice and predictable) and the -- tests (which prefer output to be deterministic). -data SimpleType = SimpleType Name [SimpleType] +data SimpleType = SimpleType SName [SimpleType] | SimpleTyLit TyLit deriving (Eq,Ord) -instHead :: ([TyVar], [PredType], Class, [Type]) -> ([Int], Name, [SimpleType]) +instHead :: ([TyVar], [PredType], Class, [Type]) -> ([Int], SName, [SimpleType]) instHead (_, _, cls, args) - = (map argCount args, className cls, map simplify args) + = (map argCount args, SName (className cls), map simplify args) argCount :: Type -> Int argCount (AppTy t _) = argCount t + 1 @@ -202,12 +211,12 @@ argCount (CastTy t _) = argCount t argCount _ = 0 simplify :: Type -> SimpleType -simplify (FunTy _ _ t1 t2) = SimpleType funTyConName [simplify t1, simplify t2] +simplify (FunTy _ _ t1 t2) = SimpleType (SName funTyConName) [simplify t1, simplify t2] simplify (ForAllTy _ t) = simplify t simplify (AppTy t1 t2) = SimpleType s (ts ++ maybeToList (simplify_maybe t2)) where (SimpleType s ts) = simplify t1 -simplify (TyVarTy v) = SimpleType (tyVarName v) [] -simplify (TyConApp tc ts) = SimpleType (tyConName tc) +simplify (TyVarTy v) = SimpleType (SName (tyVarName v)) [] +simplify (TyConApp tc ts) = SimpleType (SName (tyConName tc)) (mapMaybe simplify_maybe ts) simplify (LitTy l) = SimpleTyLit l simplify (CastTy ty _) = simplify ty @@ -218,9 +227,9 @@ simplify_maybe (CoercionTy {}) = Nothing simplify_maybe ty = Just (simplify ty) -- Used for sorting -instFam :: FamInst -> ([Int], Name, [SimpleType], Int, SimpleType) +instFam :: FamInst -> ([Int], SName, [SimpleType], Int, SimpleType) instFam FamInst { fi_fam = n, fi_tys = ts, fi_rhs = t } - = (map argCount ts, n, map simplify ts, argCount t, simplify t) + = (map argCount ts, SName n, map simplify ts, argCount t, simplify t) -------------------------------------------------------------------------------- diff --git a/html-test/ref/Bug1004.html b/html-test/ref/Bug1004.html index b4ce3c88..cd959f7f 100644 --- a/html-test/ref/Bug1004.html +++ b/html-test/ref/Bug1004.html @@ -182,135 +182,7 @@ > (Monad f, Monad g) => Monad (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

(>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b #

(>>) :: Product f g a -> Product f g b -> Product f g b #

return :: a -> Product f g a #

(Functor f, Functor g) => Functor (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

fmap :: (a -> b) -> Product f g a -> Product f g b #

(<$) :: a -> Product f g b -> Product f g a #

(MonadFix
Instance details

(Applicative f, Applicative g) => Applicative (MonadZip f, MonadZip g) => MonadZip (Product f g)

Instance details

Methods

pure :: a -> Product f g a #

(<*>)mzip :: Product f g (a -> b) -> Product f g a -> Product f g b #

liftA2 :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g c f g (a, b) #

(*>) :: mzipWith :: (a -> b -> c) -> Product f g a -> Product f g b -> Product f g b f g c #

(<*)munzip :: Product f g a -> f g (a, b) -> (Product f g b -> f g a, Product f g a f g b) #

(Foldable
Instance details

(Traversable f, Traversable g) => Traversable (Eq1 f, Eq1 g) => Eq1 (Product f g)

Instance details

Methods

traverse :: Applicative f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) #

sequenceA :: Applicative f0 => Product f g (f0 a) -> f0 (Product f g a) #

mapM :: Monad m => (a -> m b) -> Product f g a -> m (Product f g b) #

sequence :: Monad m => liftEq :: (a -> b -> Bool) -> Product f g (m a) -> m ( f g a -> Product f g a) f g b -> Bool #

(Show1Ord1 f, Show1Ord1 g) => Show1Ord1 (Product f g)
Instance details

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Product f g a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [liftCompare :: (a -> b -> Ordering) -> Product f g a] -> ShowS f g a -> Product f g b -> Ordering #

(Read1
Instance details

(Ord1Show1 f, Ord1Show1 g) => Ord1Show1 (Product f g)

Instance details

Methods

liftCompare :: (a -> b -> Ordering) -> Product f g a -> liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Product f g b -> Ordering f g a -> ShowS #

(Eq1 f, Eq1 g) => Eq1 (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

liftEq :: (a -> b -> Bool) -> Product f g a -> liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Product f g b -> Bool f g a] -> ShowS #

(MonadZip f, MonadZip g) => MonadZip (Traversable f, Traversable g) => Traversable (Product f g)
Instance details

Methods

mzip :: Product f g a -> traverse :: Applicative f0 => (a -> f0 b) -> Product f g b -> f g a -> f0 (Product f g (a, b) f g b) #

mzipWith :: (a -> b -> c) -> Product f g a -> sequenceA :: Applicative f0 => Product f g b -> f g (f0 a) -> f0 (Product f g c f g a) #

munzip :: Product f g (a, b) -> (mapM :: Monad m => (a -> m b) -> Product f g a, f g a -> m (Product f g b) #

sequence :: Monad m => Product f g (m a) -> m (Product f g a) #

(MonadPlus f, MonadPlus g) => MonadPlus (Alternative f, Alternative g) => Alternative (Product f g)
Instance details

Methods

mzeroempty :: Product f g a

mplus(<|>) :: Product f g a -> f g a #

some :: Product f g a -> Product f g [a] #

many :: Product f g a -> Product f g [a] #

(AlternativeApplicative f, AlternativeApplicative g) => AlternativeApplicative (Product f g)
Instance details

Methods

empty :: pure :: a -> Product f g a #

(<|>)(<*>) :: Product f g (a -> b) -> Product f g a -> Product f g b #

liftA2 :: (a -> b -> c) -> Product f g a -> Product f g a f g b -> Product f g c #

some(*>) :: Product f g a -> Product f g [a] f g b -> Product f g b #

many(<*) :: Product f g a -> Product f g [a] f g b -> Product f g a #

(Eq1 f, Eq1 g, Eq a) => Eq (Functor f, Functor g) => Functor (Product f g a) f g)

Instance details

Methods

(==) :: fmap :: (a -> b) -> Product f g a -> Product f g a -> Bool f g b #

(/=)(<$) :: a -> Product f g b -> Product f g a #

(Monad f, Monad g) => Monad (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

(>>=) :: Product f g a -> (a -> Product f g b) -> Product f g b #

(>>) :: Product f g a -> Product f g a -> Bool f g b -> Product f g b #

return :: a -> Product f g a #

(MonadPlus f, MonadPlus g) => MonadPlus (Product f g)

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Methods

mzero :: Product f g a #

mplus :: Product f g a -> Product f g a -> Product f g a #

(Typeable
Instance details

(Ord1 f, Ord1 g, Ord a) => Ord (Monoid (f a), Monoid (g a)) => Monoid (Product f g a)

Since: base-4.9.0.0Since: base-4.16.0.0

Instance details

Methods

comparemempty :: Product f g a -> Product f g a -> Ordering f g a #

(<)mappend :: Product f g a -> Product f g a -> Bool f g a -> Product f g a #

(<=) :: mconcat :: [Product f g a -> f g a] -> Product f g a -> Bool f g a #

(Semigroup (f a), Semigroup (g a)) => Semigroup (Product f g a)

Since: base-4.16.0.0

Instance details

Defined in Data.Functor.Product

Methods

(>)(<>) :: Product f g a -> Product f g a -> Bool f g a -> Product f g a #

(>=) :: sconcat :: NonEmpty (Product f g a -> f g a) -> Product f g a -> Bool f g a #

max :: Product f g a -> stimes :: Integral b => b -> Product f g a -> Product f g a #

Generic (Product f g a) 
Instance details

Defined in Data.Functor.Product

Associated Types

type Rep (Product f g a) :: Type -> Type #

Methods

minfrom :: Product f g a -> f g a -> Rep (Product f g a -> f g a) x #

to :: Rep (Product f g a) x -> Product f g a # (Read1

Instance details

(Show1

Instance details

Generic (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a) 

Since: base-4.9.0.0

Instance details

Defined in Data.Functor.Product

Associated Types

type Rep (Product f g a) :: Type -> Type #

Methods

from(==) :: Product f g a -> Rep ( f g a -> Product f g a) x f g a -> Bool #

to :: Rep ((/=) :: Product f g a) x -> f g a -> Product f g a f g a -> Bool #

(Semigroup (f a), Semigroup (g a)) => Semigroup (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a)

Since: base-4.16.0.0Since: base-4.9.0.0

Instance details

Methods

(<>)compare :: Product f g a -> Product f g a -> Ordering #

(<) :: Product f g a -> Product f g a f g a -> Bool #

sconcat :: NonEmpty ((<=) :: Product f g a) -> f g a -> Product f g a f g a -> Bool #

stimes :: Integral b => b -> (>) :: Product f g a -> Product f g a f g a -> Bool #

(Monoid (f a), Monoid (g a)) => Monoid (Product f g a)

Since: base-4.16.0.0

Instance details

Defined in Data.Functor.Product

Methods

mempty(>=) :: Product f g a f g a -> Product f g a -> Bool #

mappendmax :: Product f g a ->

mconcat :: [min :: Product f g a] -> f g a -> Product f g a -> Product f g a #Foo3 (a :: Char -> Char) #Foo3 (a :: Char -> Char)

Foo3 (a :: Char -> Char) #Foo3 (a :: Char -> Char)
Arrow a => Functor (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b)
Instance details

Methods

fmap :: (a0 -> b0) -> empty :: WrappedArrow a b a0 #

(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 a b a0 -> WrappedArrow a b a0 #

(<$) :: a0 -> some :: WrappedArrow a b b0 -> a b a0 -> WrappedArrow a b a0 a b [a0] #

many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #

(ArrowZero a, ArrowPlus a) => Alternative Arrow a => Functor (WrappedArrow a b)
Instance details

Methods

empty :: WrappedArrow a b a0 #

(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #

some :: fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b [a0] a b b0 #

many :: (<$) :: a0 -> WrappedArrow a b a0 -> a b b0 -> WrappedArrow a b [a0] a b a0 #

VisibleClass Int VisibleData # VisibleClass VisibleData Int # Foo [] Maybe #

foo :: [ :: Maybe Int] -> a -> [a] -> a -> Maybe a #

foo' :: [[a]] -> :: Maybe (Maybe a) -> Int -> [[ -> Maybe (Maybe Int]] ) #

Foo Maybe [] #

foo :: Maybe :: [Int -> a -> Maybe a ] -> a -> [a] #

foo' :: Maybe (Maybe a) -> :: [[a]] -> Int -> Maybe (Maybe -> [[Int) ]] #

(Eq a, Foo f) => Foo ((,) (f a)) ((<~~) a) #

foo :: (f a, :: (a <~~ Int) -> a0 -> (f a, a0) ) -> a0 -> a <~~ a0 #

foo' :: (f a, (f a, a0)) -> :: (a <~~ (a <~~ a0)) -> Int -> (f a, (f a, -> a <~~ (a <~~ Int)) ) #

(Eq a, Foo ((<~~) a) f) => Foo ((,) (f a)) #

foo :: (a <~~ :: (f a, Int) -> a0 -> a <~~ a0 ) -> a0 -> (f a, a0) #

foo' :: (a <~~ (a <~~ a0)) -> :: (f a, (f a, a0)) -> Int -> a <~~ (a <~~ -> (f a, (f a, Int) )) #

Foo ((,,) a a) (Quux a b) #

foo :: (a, a, :: Quux a b Int) -> a0 -> (a, a, a0) -> a0 -> Quux a b a0 #

foo' :: (a, a, (a, a, a0)) -> :: Quux a b (Quux a b a0) -> Int -> (a, a, (a, a, -> Quux a b (Quux a b Int)) ) #

Foo (Quux a b) ((,,) a a) #

foo :: Quux a b :: (a, a, Int -> a0 -> Quux a b a0 ) -> a0 -> (a, a, a0) #

foo' :: Quux a b (Quux a b a0) -> :: (a, a, (a, a, a0)) -> Int -> Quux a b (Quux a b -> (a, a, (a, a, Int) )) #

Foo ((,,) a b) => Bar ((,,) a b) (a, b, a) # 
Instance details

Defined in Instances

Methods

bar :: (a, b, (a, b, a)) -> (a, b, Bool) -> (a, b, a) #

bar' :: (a, b, (a, b, (a, b, a))) -> (a, b, (a, b, (a, b, b0))) #

bar0 :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -> ((a, b, b0), (a, b, c)) #

bar1 :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -> ((a, b, b0), (a, b, c)) #

Bar
Instance details

Foo ((,,) a b) => Bar ((,,) a b) (a, b, a) # 
Instance details

Defined in Instances

Methods

bar :: (a, b, (a, b, a)) -> (a, b, Bool) -> (a, b, a) #

bar' :: (a, b, (a, b, (a, b, a))) -> (a, b, (a, b, (a, b, b0))) #

bar0 :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -> ((a, b, b0), (a, b, c)) #

bar1 :: ((a, b, (a, b, a)), (a, b, (a, b, a))) -> ((a, b, b0), (a, b, c)) #

Baz (a, b, c) (Quux a b c) #

baz :: (a, b, c) -> ( :: Quux a b c -> (forall a0. a0 -> a0) -> (b0, forall c0. c0 -> (a, b, c)) -> (b0, c1) c0. c0 -> Quux a b c) -> (b0, c1) #

baz' :: b0 -> (forall b1. b1 -> (a, b, c)) -> ( b1. b1 -> Quux a b c) -> (forall b2. b2 -> (a, b, c)) -> [(b0, (a, b, c))] b2. b2 -> Quux a b c) -> [(b0, Quux a b c)] #

forall b1. (forall b2. b2 -> (a, b, c)) -> c0) -> b2. b2 -> Quux a b c) -> c0) -> forall c1. c1 -> b0 # Baz (Quux a b c) (a, b, c) #

baz :: Quux a b c -> ( :: (a, b, c) -> (forall a0. a0 -> a0) -> (b0, forall c0. c0 -> Quux a b c) -> (b0, c1) c0. c0 -> (a, b, c)) -> (b0, c1) #

baz' :: b0 -> (forall b1. b1 -> Quux a b c) -> ( b1. b1 -> (a, b, c)) -> (forall b2. b2 -> Quux a b c) -> [(b0, Quux a b c)] b2. b2 -> (a, b, c)) -> [(b0, (a, b, c))] #

forall b1. (forall b2. b2 -> Quux a b c) -> c0) -> b2. b2 -> (a, b, c)) -> c0) -> forall c1. c1 -> b0 # Functor (SomeType f) # 

Instance details

Defined in SpuriousSuperclassConstraints

Methods

fmap :: (a -> b) -> SomeType f a -> SomeType f b #

(<$) :: a -> SomeType f b -> SomeType f a #

Applicative
Instance details

Functor (SomeType f) # 
Instance details

Defined in SpuriousSuperclassConstraints

Methods

fmap :: (a -> b) -> SomeType f a -> SomeType f b #

(<$) :: a -> SomeType f b -> SomeType f a #

type X 'XXX <> (a :: Type)
'XX #
type X 'XXX <> (a :: Type) = 'XX = 'X
type 'XXX X <> 'XX (a :: Type) #
type 'XXX X <> 'XX = ' (a :: Type) = X
Test YX
#

Doc for: instance Test Y

Doc for: instance Test X

Test XY #

Doc for: instance Test X

Doc for: instance Test Y

Foo YX #

Doc for: type instance Foo Y = X

Doc for: type instance Foo X = Y

Foo Y = X = Y
Foo XY #

Doc for: type instance Foo X = Y

Doc for: type instance Foo Y = X

Foo X = Y = X
Bat YX
#

Doc for: data instance Bat Y

Doc for: data instance Bat X

Bat Y = BatY YX
Bat XY #

Doc for: data instance Bat X

Doc for: data instance Bat Y

Bat X Y = BatY Y
Assoc YX
#

Doc for: instance Assoc Y

Doc for: instance Assoc X

AssocD YX #

AssocT YX #

Assoc XY
#

Doc for: instance Assoc X

Doc for: instance Assoc Y

AssocD XY #

AssocT XY #

type Y 'XXX <> (a :: Type) 'XX #
type Y 'XXX <> (a :: Type) = a
'XX = 'X
type 'XXX Y <> 'XX (a :: Type) #
type 'XXX Y <> 'XX = 'X
(a :: Type) = a
type Foo W X #

Should be visible, but with a hidden right hand side

External instance

Instance details

Defined in TypeFamilies2TypeFamilies

type Foo W X = Y
type Foo X W #

External instance

Should be visible, but with a hidden right hand side

Instance details

Defined in TypeFamiliesTypeFamilies2

type Foo X = Y W
data
Bar W Y #

Shown because BarX is still exported despite Z being hidden

 Instance details

Defined in TypeFamilies2TypeFamilies

data Bar W = BarX Z
Y
data
Bar Y W # 

Shown because BarX is still exported despite Z being hidden

Instance details

Defined in TypeFamiliesTypeFamilies2

data Bar Y
W = BarX Z
type Bar Int () #type Bar () = Int = ()
type Bar () Int #type Bar () = Int = ()
newtypedata
Baz Double
() #

newtypedata Baz Double = Baz3 Float () = Baz1
datanewtype Baz Int Double #

datanewtype Baz Int = Baz2 Bool Double = Baz3 Float
data
Baz () Int #data Baz () = Baz1 Int = Baz2 Bool
bar :: Int -> Int barbaz :: Int -> (Int, Int) bazbar :: [a] -> Int barbaz :: Int -> ([a], [a]) baznorf :: [Int] -> Int norfquux :: ([a], [a]) -> [a] quuxplugh :: forall a b. Either a a -> Either b b -> Either (a -> b) (b -> a) plughInt -x :: Int x :: Point -> Int +x :: Int xInt -y :: Int y :: Point -> Int +y :: Int yInt -y :: Int -x :: Int -y :: Point -> Int x :: Point -> Int +y :: Point -> Int +x :: Int +y :: Int .. Date: Tue, 9 Feb 2021 12:56:15 +0100 Subject: Also make TyLit deterministic --- haddock-api/src/Haddock/Interface/AttachInstances.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface/AttachInstances.hs b/haddock-api/src/Haddock/Interface/AttachInstances.hs index d5b80888..530c5690 100644 --- a/haddock-api/src/Haddock/Interface/AttachInstances.hs +++ b/haddock-api/src/Haddock/Interface/AttachInstances.hs @@ -28,6 +28,7 @@ import Data.Maybe ( maybeToList, mapMaybe, fromMaybe ) import qualified Data.Map as Map import qualified Data.Set as Set +import GHC.Data.FastString (unpackFS) import GHC.Core.Class import GHC.Driver.Session import GHC.Core (isOrphan) @@ -194,7 +195,9 @@ instance Ord SName where -- For the benefit of the user (looks nice and predictable) and the -- tests (which prefer output to be deterministic). data SimpleType = SimpleType SName [SimpleType] - | SimpleTyLit TyLit + | SimpleIntTyLit Integer + | SimpleStringTyLit String + | SimpleCharTyLit Char deriving (Eq,Ord) @@ -218,7 +221,9 @@ simplify (AppTy t1 t2) = SimpleType s (ts ++ maybeToList (simplify_maybe t2)) simplify (TyVarTy v) = SimpleType (SName (tyVarName v)) [] simplify (TyConApp tc ts) = SimpleType (SName (tyConName tc)) (mapMaybe simplify_maybe ts) -simplify (LitTy l) = SimpleTyLit l +simplify (LitTy (NumTyLit n)) = SimpleIntTyLit n +simplify (LitTy (StrTyLit s)) = SimpleStringTyLit (unpackFS s) +simplify (LitTy (CharTyLit c)) = SimpleCharTyLit c simplify (CastTy ty _) = simplify ty simplify (CoercionTy _) = error "simplify:Coercion" -- cgit v1.2.3 From 23fa3045f14ce0b8e107178e9b7859a66db65910 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 14 Feb 2021 15:28:15 +0200 Subject: Add import list to Data.List in Haddock.Interface.Create --- haddock-api/haddock-api.cabal | 1 + haddock-api/src/Haddock/Interface/Create.hs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'haddock-api/src') diff --git a/haddock-api/haddock-api.cabal b/haddock-api/haddock-api.cabal index e6de8b81..e9433d73 100644 --- a/haddock-api/haddock-api.cabal +++ b/haddock-api/haddock-api.cabal @@ -68,6 +68,7 @@ library ghc-options: -funbox-strict-fields -O2 -Wall -Wcompat + -Wcompat-unqualified-imports -Widentities -Wredundant-constraints -Wnoncanonical-monad-instances diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs index 9a773b6c..c0b9fd46 100644 --- a/haddock-api/src/Haddock/Interface/Create.hs +++ b/haddock-api/src/Haddock/Interface/Create.hs @@ -35,7 +35,7 @@ import Control.Monad.Writer.Strict hiding (tell) import Data.Bitraversable import qualified Data.Map as M import Data.Map (Map) -import Data.List +import Data.List (foldl', find) import Data.Maybe import Data.Traversable import GHC.Stack -- cgit v1.2.3 From af46d073aa254bdede248fa8d2f5deb412968317 Mon Sep 17 00:00:00 2001 From: Hécate Moonlight Date: Mon, 22 Feb 2021 11:53:07 +0100 Subject: Clean-up of Interface and Interface.Create's imports and pragmata --- haddock-api/src/Haddock/Interface.hs | 23 +++++++------ haddock-api/src/Haddock/Interface/Create.hs | 51 +++++++++++++++++------------ 2 files changed, 41 insertions(+), 33 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface.hs b/haddock-api/src/Haddock/Interface.hs index 7cc76953..74dbc9c7 100644 --- a/haddock-api/src/Haddock/Interface.hs +++ b/haddock-api/src/Haddock/Interface.hs @@ -51,26 +51,25 @@ import qualified Data.Map as Map import qualified Data.Set as Set import Text.Printf -import GHC.Unit.Module.Env (mkModuleSet, emptyModuleSet, unionModuleSet, ModuleSet) -import GHC.Unit.Module.ModSummary -import GHC.Unit.Module.Graph -import GHC.Unit.Types -import GHC.Data.Graph.Directed -import GHC.Driver.Session hiding (verbosity) import GHC hiding (verbosity) +import GHC.Data.FastString (unpackFS) +import GHC.Data.Graph.Directed import GHC.Driver.Env import GHC.Driver.Monad -import GHC.Data.FastString (unpackFS) -import GHC.Utils.Error +import GHC.Driver.Session hiding (verbosity) +import GHC.HsToCore.Docs +import GHC.Plugins (Outputable, StaticPlugin(..), Plugin(..), PluginWithArgs(..), defaultPlugin, keepRenamedSource) import GHC.Tc.Types (TcM, TcGblEnv(..)) -import GHC.Tc.Utils.Monad (getTopEnv, setGblEnv) import GHC.Tc.Utils.Env (tcLookupGlobal) +import GHC.Tc.Utils.Monad (getTopEnv, setGblEnv) import GHC.Types.Name (nameIsFromExternalPackage, nameOccName) import GHC.Types.Name.Occurrence (isTcOcc) import GHC.Types.Name.Reader (unQualOK, greMangledName, globalRdrEnvElts) -import GHC.HsToCore.Docs -import GHC.Plugins (Outputable, StaticPlugin(..), Plugin(..), PluginWithArgs(..), - defaultPlugin, keepRenamedSource) +import GHC.Unit.Module.Env (mkModuleSet, emptyModuleSet, unionModuleSet, ModuleSet) +import GHC.Unit.Module.Graph +import GHC.Unit.Module.ModSummary +import GHC.Unit.Types +import GHC.Utils.Error #if defined(mingw32_HOST_OS) import System.IO diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs index c0b9fd46..a921342e 100644 --- a/haddock-api/src/Haddock/Interface/Create.hs +++ b/haddock-api/src/Haddock/Interface/Create.hs @@ -1,8 +1,17 @@ -{-# LANGUAGE StandaloneDeriving, FlexibleInstances, MultiParamTypeClasses, CPP, TupleSections, BangPatterns, LambdaCase, NamedFieldPuns, ScopedTypeVariables, RecordWildCards #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE BangPatterns #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DerivingStrategies #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TupleSections #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE ViewPatterns #-} {-# OPTIONS_GHC -Wwarn #-} ----------------------------------------------------------------------------- -- | @@ -38,33 +47,33 @@ import Data.Map (Map) import Data.List (foldl', find) import Data.Maybe import Data.Traversable -import GHC.Stack -import GHC.Tc.Utils.Monad (finalSafeMode) -import GHC.Types.Avail hiding (avail) -import qualified GHC.Types.Avail as Avail -import qualified GHC.Unit.Module as Module -import GHC.Unit.Module.ModSummary -import qualified GHC.Types.SrcLoc as SrcLoc -import GHC.Types.SourceFile -import GHC.Core.Class -import GHC.Core.ConLike (ConLike(..)) +import GHC.Stack import GHC hiding (lookupName) +import GHC.Core.Class +import GHC.Core.ConLike (ConLike (..)) +import GHC.Data.FastString (bytesFS, unpackFS) import GHC.Driver.Ppr +import GHC.HsToCore.Docs hiding (mkMaps) +import GHC.Parser.Annotation (IsUnicodeSyntax (..)) +import GHC.Tc.Types hiding (IfM) +import GHC.Tc.Utils.Monad (finalSafeMode) +import GHC.Types.Avail hiding (avail) +import qualified GHC.Types.Avail as Avail +import GHC.Types.Basic (PromotionFlag (..)) import GHC.Types.Name -import GHC.Types.Name.Set import GHC.Types.Name.Env -import GHC.Unit.State import GHC.Types.Name.Reader -import GHC.Tc.Types hiding (IfM) -import GHC.Data.FastString ( unpackFS, bytesFS ) -import GHC.Types.Basic ( PromotionFlag(..) ) +import GHC.Types.Name.Set +import GHC.Types.SourceFile import GHC.Types.SourceText +import qualified GHC.Types.SrcLoc as SrcLoc +import qualified GHC.Unit.Module as Module +import GHC.Unit.Module.ModSummary +import GHC.Unit.Module.Warnings +import GHC.Unit.State import qualified GHC.Utils.Outputable as O import GHC.Utils.Panic -import GHC.HsToCore.Docs hiding (mkMaps) -import GHC.Parser.Annotation (IsUnicodeSyntax(..)) -import GHC.Unit.Module.Warnings newtype IfEnv m = IfEnv { -- cgit v1.2.3 From f2bd833fdc6f49bb33ab9df12e18e194453bff03 Mon Sep 17 00:00:00 2001 From: Hécate Moonlight Date: Mon, 22 Feb 2021 18:41:08 +0100 Subject: Explicit imports for Haddock.Interface and Haddock.Interface.Create --- haddock-api/src/Haddock/Interface.hs | 48 ++++++++++++++-------------- haddock-api/src/Haddock/Interface/Create.hs | 49 +++++++++++++++-------------- 2 files changed, 50 insertions(+), 47 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface.hs b/haddock-api/src/Haddock/Interface.hs index 74dbc9c7..fd44e58b 100644 --- a/haddock-api/src/Haddock/Interface.hs +++ b/haddock-api/src/Haddock/Interface.hs @@ -34,42 +34,44 @@ module Haddock.Interface ( ) where -import Haddock.GhcUtils -import Haddock.InterfaceFile -import Haddock.Interface.Create -import Haddock.Interface.AttachInstances -import Haddock.Interface.Rename +import Haddock.GhcUtils (moduleString, pretty) +import Haddock.Interface.AttachInstances (attachInstances) +import Haddock.Interface.Create (createInterface1, runIfM) +import Haddock.Interface.Rename (renameInterface) +import Haddock.InterfaceFile (InterfaceFile, ifInstalledIfaces, ifLinkEnv) import Haddock.Options hiding (verbosity) -import Haddock.Types -import Haddock.Utils - -import Control.Monad -import Control.Monad.IO.Class ( MonadIO ) -import Data.IORef +import Haddock.Types (DocOption (..), Documentation (..), ExportItem (..), IfaceMap, InstIfaceMap, Interface, LinkEnv, + expItemDecl, expItemMbDoc, ifaceDoc, ifaceExportItems, ifaceExports, ifaceHaddockCoverage, + ifaceInstances, ifaceMod, ifaceOptions, ifaceVisibleExports, instMod, runWriter, throwE) +import Haddock.Utils (Verbosity (..), normal, out, verbose) + +import Control.Monad (unless, when) +import Control.Monad.IO.Class (MonadIO, liftIO) +import Data.IORef (atomicModifyIORef', newIORef, readIORef) import Data.List (foldl', isPrefixOf, nub) +import Text.Printf (printf) import qualified Data.Map as Map import qualified Data.Set as Set -import Text.Printf import GHC hiding (verbosity) import GHC.Data.FastString (unpackFS) -import GHC.Data.Graph.Directed -import GHC.Driver.Env -import GHC.Driver.Monad +import GHC.Data.Graph.Directed (flattenSCCs) +import GHC.Driver.Env (hsc_dflags, hsc_home_unit, hsc_logger, hsc_static_plugins, hsc_units) +import GHC.Driver.Monad (modifySession, withTimingM) import GHC.Driver.Session hiding (verbosity) import GHC.HsToCore.Docs -import GHC.Plugins (Outputable, StaticPlugin(..), Plugin(..), PluginWithArgs(..), defaultPlugin, keepRenamedSource) -import GHC.Tc.Types (TcM, TcGblEnv(..)) +import GHC.Plugins (Outputable, Plugin (..), PluginWithArgs (..), StaticPlugin (..), defaultPlugin, keepRenamedSource) +import GHC.Tc.Types (TcGblEnv (..), TcM) import GHC.Tc.Utils.Env (tcLookupGlobal) import GHC.Tc.Utils.Monad (getTopEnv, setGblEnv) import GHC.Types.Name (nameIsFromExternalPackage, nameOccName) import GHC.Types.Name.Occurrence (isTcOcc) -import GHC.Types.Name.Reader (unQualOK, greMangledName, globalRdrEnvElts) -import GHC.Unit.Module.Env (mkModuleSet, emptyModuleSet, unionModuleSet, ModuleSet) -import GHC.Unit.Module.Graph -import GHC.Unit.Module.ModSummary -import GHC.Unit.Types -import GHC.Utils.Error +import GHC.Types.Name.Reader (globalRdrEnvElts, greMangledName, unQualOK) +import GHC.Unit.Module.Env (ModuleSet, emptyModuleSet, mkModuleSet, unionModuleSet) +import GHC.Unit.Module.Graph (ModuleGraphNode (..)) +import GHC.Unit.Module.ModSummary (emsModSummary, isBootSummary) +import GHC.Unit.Types (IsBootInterface (..)) +import GHC.Utils.Error (withTiming) #if defined(mingw32_HOST_OS) import System.IO diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs index a921342e..b039e095 100644 --- a/haddock-api/src/Haddock/Interface/Create.hs +++ b/haddock-api/src/Haddock/Interface/Create.hs @@ -32,48 +32,49 @@ module Haddock.Interface.Create (IfM, runIfM, createInterface1) where import Documentation.Haddock.Doc (metaDocAppend) +import Haddock.Convert (PrintRuntimeReps (..), tyThingToLHsDecl) +import Haddock.GhcUtils (addClassContext, filterSigNames, lHsQTyVarsToTypes, mkEmptySigType, moduleString, parents, + pretty, restrictTo, sigName, unL) +import Haddock.Interface.LexParseRn (processDocString, processDocStringParas, processDocStrings, processModuleHeader) +import Haddock.Options (Flag (..), modulePackageInfo) import Haddock.Types hiding (liftErrMsg) -import Haddock.Options -import Haddock.GhcUtils -import Haddock.Utils -import Haddock.Convert -import Haddock.Interface.LexParseRn +import Haddock.Utils (replace) -import Control.Monad.Reader +import Control.Monad.Reader (MonadReader (..), ReaderT, asks, runReaderT) import Control.Monad.Writer.Strict hiding (tell) -import Data.Bitraversable -import qualified Data.Map as M +import Data.Bitraversable (bitraverse) +import Data.List (find, foldl') import Data.Map (Map) -import Data.List (foldl', find) -import Data.Maybe -import Data.Traversable +import qualified Data.Map as M +import Data.Maybe (catMaybes, fromJust, isJust, mapMaybe, maybeToList) +import Data.Traversable (for) -import GHC.Stack import GHC hiding (lookupName) -import GHC.Core.Class +import GHC.Core.Class (ClassMinimalDef, classMinimalDef) import GHC.Core.ConLike (ConLike (..)) import GHC.Data.FastString (bytesFS, unpackFS) -import GHC.Driver.Ppr +import GHC.Driver.Ppr (showSDoc) import GHC.HsToCore.Docs hiding (mkMaps) import GHC.Parser.Annotation (IsUnicodeSyntax (..)) +import GHC.Stack (HasCallStack) import GHC.Tc.Types hiding (IfM) import GHC.Tc.Utils.Monad (finalSafeMode) import GHC.Types.Avail hiding (avail) import qualified GHC.Types.Avail as Avail import GHC.Types.Basic (PromotionFlag (..)) -import GHC.Types.Name -import GHC.Types.Name.Env -import GHC.Types.Name.Reader -import GHC.Types.Name.Set -import GHC.Types.SourceFile -import GHC.Types.SourceText +import GHC.Types.Name (getOccString, getSrcSpan, isDataConName, isValName, nameIsLocalOrFrom, nameOccName) +import GHC.Types.Name.Env (lookupNameEnv) +import GHC.Types.Name.Reader (GlobalRdrEnv, greMangledName, lookupGlobalRdrEnv) +import GHC.Types.Name.Set (elemNameSet, mkNameSet) +import GHC.Types.SourceFile (HscSource (..)) +import GHC.Types.SourceText (SourceText (..), sl_fs) import qualified GHC.Types.SrcLoc as SrcLoc import qualified GHC.Unit.Module as Module -import GHC.Unit.Module.ModSummary -import GHC.Unit.Module.Warnings -import GHC.Unit.State +import GHC.Unit.Module.ModSummary (msHsFilePath) +import GHC.Unit.Module.Warnings (WarningTxt (..), Warnings (..)) +import GHC.Unit.State (PackageName (..), UnitState, lookupModuleInAllUnits) import qualified GHC.Utils.Outputable as O -import GHC.Utils.Panic +import GHC.Utils.Panic (pprPanic) newtype IfEnv m = IfEnv { -- cgit v1.2.3 From 5a6b3811fe50d0b257e4baa183c9f4ad8e701081 Mon Sep 17 00:00:00 2001 From: Hécate Moonlight Date: Tue, 23 Feb 2021 12:36:12 +0100 Subject: Fix the call-site of guessTarget in Interface.hs Explicit the imports from GHC.HsToCore.Docs --- haddock-api/src/Haddock/Interface.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'haddock-api/src') diff --git a/haddock-api/src/Haddock/Interface.hs b/haddock-api/src/Haddock/Interface.hs index fd44e58b..b42ae1a3 100644 --- a/haddock-api/src/Haddock/Interface.hs +++ b/haddock-api/src/Haddock/Interface.hs @@ -59,7 +59,7 @@ import GHC.Data.Graph.Directed (flattenSCCs) import GHC.Driver.Env (hsc_dflags, hsc_home_unit, hsc_logger, hsc_static_plugins, hsc_units) import GHC.Driver.Monad (modifySession, withTimingM) import GHC.Driver.Session hiding (verbosity) -import GHC.HsToCore.Docs +import GHC.HsToCore.Docs (getMainDeclBinder) import GHC.Plugins (Outputable, Plugin (..), PluginWithArgs (..), StaticPlugin (..), defaultPlugin, keepRenamedSource) import GHC.Tc.Types (TcGblEnv (..), TcM) import GHC.Tc.Utils.Env (tcLookupGlobal) @@ -158,7 +158,7 @@ createIfaces verbosity modules flags instIfaceMap = do -- alive to be able to find all the instances. modifySession installHaddockPlugin - targets <- mapM (\filePath -> guessTarget filePath Nothing Nothing) modules + targets <- mapM (\filePath -> guessTarget filePath Nothing) modules setTargets targets loadOk <- withTimingM "load" (const ()) $ -- cgit v1.2.3