deriving Generic does not work with TypeLits
{-# LANGUAGE DataKinds, KindSignatures #-}
{-# LANGUAGE DeriveGeneric #-}
import GHC.TypeLits
import GHC.Generics
data F (a :: Symbol)
data X = X (F "hello") deriving Generic
Trying to derive Generics instance for simple datatype with Symbol inside but GHC complains:
Can't make a derived instance of `Generic X':
X must not have unlifted or polymorphic arguments
In the data declaration for `X'
I found that this could be fixed by adding single line to isTauTy:
--- a/compiler/typecheck/TcType.lhs
+++ b/compiler/typecheck/TcType.lhs
@@ -899,6 +899,7 @@ mkTcEqPred ty1 ty2
isTauTy :: Type -> Bool
isTauTy ty | Just ty' <- tcView ty = isTauTy ty'
isTauTy (TyVarTy _) = True
+isTauTy (LitTy _) = True
isTauTy (TyConApp tc tys) = all isTauTy tys && isTauTyCon tc
isTauTy (AppTy a b) = isTauTy a && isTauTy b
isTauTy (FunTy a b) = isTauTy a && isTauTy b
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | Bug |
TypeOfFailure | ValidProgramRejected |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |