Skip to content

"Illegal instance for type synonym" while deriving Typeable1 for data type

This occured to me in network-ip package today:

{-# LANGUAGE StandaloneDeriving #-}
module Repro where

import Data.Typeable (Typeable1)

data InetAddr a = InetAddr
deriving instance Typeable1 InetAddr

Results in GHC complaining with:

repro.hs:7:19: error:
    * Illegal instance for a type synonym
      A class instance must be for a class
    * In the stand-alone deriving instance for `Typeable1 InetAddr'
  |
7 | deriving instance Typeable1 InetAddr
  |                   ^^^^^^^^^^^^^^^^^^

This is due to Typeable1 defined as type synonym for Typeable (see here http://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Typeable.html#t:Typeable1).

I see it is deprecated but I would still expect it to work correctly still.

Edited by Alex Biehl
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information