Opened 6 months ago

Last modified 2 months ago

#8486 new bug

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

Reported by: aavogt Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets: 5682

Description

Hi,

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

<interactive>:24:1:
    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 (6)

comment:1 Changed 6 months 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 months ago by monoidal

See also #5682.

comment:3 Changed 6 months ago by dreixel

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

comment:4 Changed 2 months 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 2 months ago by dreixel

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

comment:6 Changed 2 months 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.

Note: See TracTickets for help on using tickets.