Opened 6 years ago

Closed 6 years ago

#7800 closed bug (fixed)

Error message when deriving Typeable without PolyKinds

Reported by: monoidal Owned by:
Priority: normal Milestone: 7.8.1
Component: Compiler Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case: deriving/should_fail/T7800
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Module M:

{-# LANGUAGE PolyKinds #-}
module M where

data A a

Module N:

{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable #-}
module N where

import M
import Data.Typeable

deriving instance Typeable A

We get a confusing error message:

    Derived typeable instance must be of form (Typeable A)
    In the stand-alone deriving instance for ‛Typeable A’

The error disappears when N is compiled with -XPolyKinds. The reason is: without -XPolyKinds, A defaults to A *. I think it's simplest to suggest the flag in the error message.

Attachments (2)

0001-Better-error-message-when-deriving-Typeable-without-.patch (2.4 KB) - added by monoidal 6 years ago.
0001-Test-for-7800.patch (2.8 KB) - added by monoidal 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by dreixel

Owner: set to dreixel

I agree that this error message is confusing, thanks for reporting. I'll look into it.

comment:2 Changed 6 years ago by igloo

difficulty: Unknown
Milestone: 7.8.1

comment:3 Changed 6 years ago by monoidal

dreixel: I think it would be good to fix this before 7.8. Is it OK that I only edit the message to include "If you are deriving Typeable for a polykinded datatype, make sure PolyKinds is on"? This is rather blunt but it's a working solution.

comment:4 Changed 6 years ago by dreixel

Sorry, I forgot about this. And I won't have much time to look at it before ICFP. So yes, please do change the message; it's an improvement.

Changed 6 years ago by monoidal

Attachment: 0001-Test-for-7800.patch added

comment:5 Changed 6 years ago by monoidal

Owner: dreixel deleted

comment:6 Changed 6 years ago by monoidal

Status: newpatch

comment:7 Changed 6 years ago by Simon Peyton Jones <simonpj@…>

In 86033a00d6af909be1f8ac3a638529144ccc26d2/ghc:

Improve error message for deriving polykinded Typeable (Trac #7800)

Thanks to Krzysztof Gogolewski (monoidal) for the first draft of this patch

comment:8 Changed 6 years ago by Simon Peyton Jones <simonpj@…>

comment:9 Changed 6 years ago by simonpj

Resolution: fixed
Status: patchclosed
Test Case: deriving/should_fail/T7800
Note: See TracTickets for help on using tickets.