diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2019-02-03 22:58:58 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-03 22:58:58 -0800 |
commit | aa9644fc4179de044557438f2bd3003642750a97 (patch) | |
tree | d2c0767d85a6be4c71f7c64c232c44ad4db0e15b /haddock-api/src/Haddock/Backends/Hoogle.hs | |
parent | a0973d09a5b4f6a08b35c0b3de371c895d7d847a (diff) |
Miscellaneous improvements to `Convert` (#1020)
Now that Haddock is moving towards working entirely over `.hi` and `.hie` files,
all declarations and types are going to be synthesized via the `Convert` module.
In preparation for this change, here are a bunch of fixes to this module:
* Add kind annotations to type variables in `forall`'s whose kind is not `Type`,
unless the kind can be inferred from some later use of the variable. See
`implicitForAll` and `noKindTyVars` in particular if you wish to dive into this.
* Properly detect `HsQualTy` in `synifyType`. This is done by following suit with
what GHC's `toIfaceTypeX` does and checking the first argument of
`FunTy{} :: Type` to see if it classified as a given/wanted in the typechecker
(see `isPredTy`).
* Beef up the logic around figuring out when an explicit `forall` is needed. This
includes: observing if any of the type variables will need kind signatures, if the
inferred type variable order _without_ a forall will still match the one GHC
claims, and some other small things.
* Add some (not yet used) functionality for default levity polymorphic type
signatures. This functionality similar to `fprint-explicit-runtime-reps`.
Couple other smaller fixes only worth mentioning:
* Show the family result signature only when it isn't `Type`
* Fix rendering of implicit parameters in the LaTeX and Hoogle backends
* Better handling of the return kind of polykinded H98 data declarations
* Class decls produced by `tyThingToLHsDecl` now contain associated type
defaults and default method signatures when appropriate
* Filter out more `forall`'s in pattern synonyms
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hoogle.hs')
-rw-r--r-- | haddock-api/src/Haddock/Backends/Hoogle.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index 16ec582e..9e3186e5 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -263,8 +263,13 @@ ppCtor dflags dat subdocs con@ConDeclH98 {} -- docs for con_names on why it is a list to begin with. name = commaSeparate dflags . map unL $ getConNames con - resType = apps $ map (reL . HsTyVar NoExt NotPromoted . reL) $ - (tcdName dat) : [hsTyVarName v | L _ v@(UserTyVar _ _) <- hsQTvExplicit $ tyClDeclTyVars dat] + tyVarArg (UserTyVar _ n) = HsTyVar NoExt NotPromoted n + tyVarArg (KindedTyVar _ n lty) = HsKindSig NoExt (reL (HsTyVar NoExt NotPromoted n)) lty + tyVarArg _ = panic "ppCtor" + + resType = apps $ map reL $ + (HsTyVar NoExt NotPromoted (reL (tcdName dat))) : + map (tyVarArg . unLoc) (hsQTvExplicit $ tyClDeclTyVars dat) ppCtor dflags _dat subdocs con@(ConDeclGADT { }) = concatMap (lookupCon dflags subdocs) (getConNames con) ++ f |