Skip to content

Missing checks when deriving special classes

For the following program

{-# LANGUAGE DeriveAnyClass #-}
module T where

import Data.Coerce
import Data.Typeable

data A = MkA deriving ((~) A)
data B = MkB deriving (Coercible B)

the deriving clause for A is accepted without complaints, and the deriving clause for B fails with the following error:

T.hs:8:24: error:
    Top-level bindings for unlifted types aren't allowed:
  |
8 | data B = MkB deriving (Coercible B)
  |                        ^^^^^^^^^^^

Corresponding standalone deriving instances trigger errors saying "Manual instances of this class are not permitted". Probably similar error messages should be triggered here.

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