Skip to content

DeriveFunctor and friends don't understand type families

{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}

data Test ext a where
  Foo :: a -> Test ext a
  Extend :: (ExtensionType ext a) -> Test ext a

type family ExtensionType ext a
data ListExtension
type instance ExtensionType ListExtension a = [a]

deriving instance Functor (Test ListExtension)

{-

a.hs:15:1: error:
    • Can't make a derived instance of ‘Functor (Test ListExtension)’:
        Constructor ‘Extend’ must use the type variable only as the last argument of a data type
    • In the stand-alone deriving instance for
        ‘Functor (Test ListExtension)’
   |
15 | deriving instance Functor (Test ListExtension)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, modules loaded: none.
-}
Trac metadata
Trac field Value
Version 8.2.1-rc2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information