Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9205 closed bug (fixed)

Deriving Typeable for poly-kinded data family gives confusing error message

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

Description

The following works fine:

{-# LANGUAGE TypeFamilies, DeriveDataTypeable, StandaloneDeriving #-}
module Test where

import Data.Typeable

class Foo a where
  data family Bar a
  
deriving instance (Typeable Bar)

However, if I add -XPolyKinds, I get a horribly confusing error:

Test.hs:9:1:
    Can't make a derived instance of ‘Typeable Bar’:
      Deriving Typeable is not allowed for family instances;
      derive Typeable for ‘Bar’ alone
    In the stand-alone deriving instance for ‘Typeable Bar’

The correct way to resolve the error is to add a monomorphic kind signature to Bar, e.g. data family Bar (a :: *). Perhaps the error message could suggest this?

Change History (5)

comment:1 Changed 6 years ago by dreixel

Resolution: fixed
Status: newclosed

This is fixed in HEAD.

comment:2 Changed 6 years ago by simonpj

Fixed, as in: it compiles with or without PolyKinds.

comment:3 in reply to:  2 Changed 6 years ago by dreixel

Replying to simonpj:

Fixed, as in: it compiles with or without PolyKinds.

Which is what we want, right?

comment:4 Changed 6 years ago by simonpj

Yes, that's what we want. I was just clarifying what "fixed" meant; you could have meant "rejected with a better error message".

comment:5 Changed 6 years ago by dreixel

Right, thanks!

Note: See TracTickets for help on using tickets.