[GHC] #10030: packageName for GHC.Generics.Datatype

GHC ghc-devs at haskell.org
Tue Jan 27 07:06:53 UTC 2015


#10030: packageName for GHC.Generics.Datatype
-------------------------------------+-------------------------------------
              Reporter:  phadej      |             Owner:
                  Type:  feature     |            Status:  new
  request                            |         Milestone:
              Priority:  normal      |           Version:  7.8.4
             Component:              |  Operating System:  Unknown/Multiple
  libraries/base                     |   Type of failure:  None/Unknown
              Keywords:              |        Blocked By:
          Architecture:              |   Related Tickets:
  Unknown/Multiple                   |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------
 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
 }}}

 https://gist.github.com/phadej/8b628d579ddf6958d937
 motivated by: http://stackoverflow.com/questions/28159068/packagename-
 with-ghc-generics

 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
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10030>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list