Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#8486 closed bug (fixed)

cannot derive new-typeable instances for promoted data types taking parameters

Reported by: aavogt Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: 5682 Differential Rev(s):
Wiki Page:



The following code shows the issue:

{-# LANGUAGE DataKinds, DeriveDataTypeable, KindSignatures, PolyKinds, StandaloneDeriving #-}
import Data.Typeable
import GHC.TypeLits

data T (a :: [*]) = T deriving (Typeable)

t = T :: T [Int, Double]

deriving instance Typeable '[]

*Main> typeOf t

    No instance for (Typeable (* -> [*] -> [*]) ((':) *))
      arising from a use of ‛typeOf’
    In the expression: typeOf t
    In an equation for ‛it’: it = typeOf t

ghc7.7-20131004 doesn't allow either of the following:

deriving instance (Typeable a, Typeable b) => Typeable (a ': b)
-- or
deriving instance Typeable (':)

On ghc-7.6 I could write my own instance Typeable (T a), but this has been disabled it seems.

Change History (9)

comment:1 Changed 6 years ago by aavogt

It seems I can do deriving instance Typeable Left, so maybe it's just a minor adjustment to the parser needed?

comment:2 Changed 6 years ago by monoidal

See also #5682.

comment:3 Changed 6 years ago by dreixel

Yes, I think this is another instance of #5682.

comment:4 Changed 6 years ago by goldfire

I'm working on #5682, but I would think that Typeable instances for data constructors exported from base should also be exported from base. Otherwise, there will be orphan instances that might conflict.

comment:5 Changed 6 years ago by dreixel

I agree. But currently we can't even define those instances in base.

comment:6 Changed 6 years ago by goldfire

#5682 is now fixed in HEAD, so these instances should indeed be definable. I suppose we can be sure that users don't define instances (because they wouldn't parse), so if this gets fixed in time in base, that might be mergeable into 7.8.1.

comment:7 Changed 5 years ago by aavogt

Resolution: fixed
Status: newclosed

The instance is missing from 7.8.1's base. But I can now define the orphan myself.

comment:8 Changed 5 years ago by goldfire

Just posted #9111 requesting that base export these instances.

comment:9 Changed 5 years ago by hvr

Milestone: 7.8.1
Note: See TracTickets for help on using tickets.