Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Haddock renders imported data types with polymorphic return kinds incorrectly #1004

Closed
@RyanGlScott

Description

@RyanGlScott

(Originally discovered in well-typed/generics-sop#92).

Run Haddock on this file:

module Bug (Product(..)) where

import Data.Functor.Product

And you'll get this:

haddock

That return kind is entirely wrong, given that we're also pretty-printing the type variable binders for Product itself. I was under the false impression that I had already fixed this issue in #702, but now that I look more carefully at the code that I added:

synifyDataTyConReturnKind :: TyCon -> Maybe (LHsKind GhcRn)
synifyDataTyConReturnKind tc
= case splitFunTys (tyConKind tc) of
(_, ret_kind)
| isLiftedTypeKind ret_kind -> Nothing -- Don't bother displaying :: *
| otherwise -> Just (synifyKindSig ret_kind)

It turns out my solution wasn't sufficiently general. We're using splitFunTys here, but that won't work in the case where the return kind is headed by a forall (such as in the example above). A more robust solution is to use dropForAlls followed by splitFunTys.

Patch incoming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions