Opened 2 years ago

Closed 2 years ago

Last modified 16 months ago

#10030 closed feature request (fixed)

packageName for GHC.Generics.Datatype

Reported by: phadej Owned by: dreixel
Priority: normal Milestone: 8.0.1
Component: libraries/base Version: 7.11
Keywords: Generics Cc: hvr, ekmett
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D631
Wiki Page:


Seems it's perfectly ok to have the data type of the same name in the same module, but different packages. Yet used in the same module:

{-# LANGUAGE PackageImports #-}
{-# LANGUAGE RankNTypes #-}
module Data.Foo where
import "void" Data.Void as A
import Data.Void as B
foo :: A.Void -> a
foo = absurd
bar :: B.Void -> a
bar x = x ()
{-# LANGUAGE RankNTypes #-}
module Data.Void where
type Void = forall a b. a -> b motivated by:

I'd propose to change Datatype class to be:

class Datatype d where
  -- | The name of the datatype (unqualified)
  datatypeName :: t d (f :: * -> *) a -> [Char]
  -- | The fully-qualified name of the module where the type is declared
  moduleName   :: t d (f :: * -> *) a -> [Char]
  -- | The package name of the module where the type is declared
  packageName :: t d (f :: * -> *) a -> [Char]
  -- | Marks if the datatype is actually a newtype
  isNewtype    :: t d (f :: * -> *) a -> Bool
  isNewtype _ = False

Change History (9)

comment:1 Changed 2 years ago by dreixel


Sounds perfectly reasonable and straightforward to me.

comment:2 Changed 2 years ago by simonpj

Owner: set to dreixel

I don't understand this ticket. Some code is given, but no wrong behaviour is explained. What happens that shouldn't happen?

Pedro, Generics is your bailiwick: can you fix?

Is it serious? Or just a little glitch? Could you write unsafeCoerce? What milestone for fixing?


comment:3 Changed 2 years ago by dreixel

It's just about adding more meta-information to the GHC.Generics.Datatype class, which currently does not tell you which package the datatype is coming from. It's not a bug, it's a feature request. I can implement it, but it can also be a nice little project for anyone wishing to start working with GHC.

comment:4 Changed 2 years ago by phadej

I could take a look on this myself.

comment:5 Changed 2 years ago by phadej

Differential Rev(s): Phab:D631
Status: newpatch

comment:6 Changed 2 years ago by Austin Seipp <austin@…>

In ae39c5c040f121947e14877c3ceb47bbe80c0ccb/ghc:

Add packageName to GHC.Generics.Datatype

Summary: Added packageName to GHC.Generics.Datatype class definition

Reviewers: hvr, dreixel, austin

Reviewed By: dreixel, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10030

comment:7 Changed 2 years ago by thoughtpolice

Milestone: 7.12.1
Resolution: fixed
Status: patchclosed

Merged, thanks!

comment:8 Changed 23 months ago by thoughtpolice


Milestone renamed

comment:9 Changed 16 months ago by RyanGlScott

Keywords: Generics added
Note: See TracTickets for help on using tickets.