Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#7704 closed bug (fixed)

Phantom types break new polykind Typeable with either StandaloneDeriving or AutoDeriveTypeable

Reported by: nwf Owned by: dreixel
Priority: normal Milestone:
Component: Compiler Version: 7.7
Keywords: Cc: kazu@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: deriving/should_compile/T7704
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This test program, reduced from an attempt to bring ekmett's tagged package to HEAD,

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE AutoDeriveTypeable #-}

newtype Tagged s b = Tagged { unTagged :: b }

results in

GHCi, version 7.7.20130218:  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( typeable.hs, interpreted )

    Derived typeable instance must be of form (Typeable Tagged)
    In the stand-alone deriving instance for
      `Data.Typeable.Internal.Typeable Tagged'

This message is also emitted if I replace AutoDeriveTypeable StandaloneDeriving and deriving instance Typeable Tagged.

However, a "deriving (Typeable)" clause on the newtype definition works just fine.

Change History (8)

comment:1 Changed 4 years ago by dreixel

Owner: set to dreixel

Thanks for reporting; I'll look into it.

comment:2 Changed 4 years ago by kazu-yamamoto

Cc: kazu@… added

comment:3 Changed 4 years ago by kazu-yamamoto

Removing PolyKinds works in my environment.

comment:4 Changed 4 years ago by monoidal

In fact the "deriving (Typeable)" clause does not work either:

{-# LANGUAGE DeriveDataTypeable, PolyKinds #-}

import Data.Typeable

newtype Tagged s b = Tagged { unTagged :: b } deriving (Typeable)

k :: Typeable u => u -> Int
k _ = 0

m = k (Tagged 0 :: Tagged Int Int)

(The code compiles without PolyKinds.)

comment:5 Changed 4 years ago by jpm@…

commit 25234646e96922e3f39e85134521da8552da42ad

Author: Jose Pedro Magalhaes <>
Date:   Fri Mar 8 08:35:11 2013 +0000

    Properly instantiate the kind of the tycon when deriving Typeable (FIX #7704)

 compiler/typecheck/TcDeriv.lhs |   51 ++++++++++++++++++++++++---------------
 1 files changed, 31 insertions(+), 20 deletions(-)

comment:6 Changed 4 years ago by dreixel

Resolution: fixed
Status: newclosed

Fixed, thanks for the report.

comment:7 Changed 4 years ago by simonpj

difficulty: Unknown
Test Case: deriving/should_compile/T7704

comment:8 Changed 4 years ago by dreixel

Thanks for setting the testcase; I don't seem to be able to do that.

Note: See TracTickets for help on using tickets.