使用 GHC 泛型时参数类型错误

Wrong argument kind when using GHC Generics

我一直在按照 GHC.Generics 教程制作一个简单的通用类型类来为任意类型提供默认值。但是,当我尝试加载我的文件时(相关片段,仍然会产生错误)

{-# LANGUAGE DefaultSignatures, DeriveGeneric, TypeOperators, FlexibleContexts #-}
import GHC.Generics

class Default a where
    def :: a
    default def :: (Generic a, GDefault (Rep a)) => a
    def = to gdef

class GDefault f where
    gdef :: f a

instance (Default a, Default b) => GDefault (a :+: b) where
    gdef (L1 x) = gdef x
    gdef (R1 x) = gdef x

我收到以下错误:

Generic.hs:12:46:
    The first argument of ‘:+:’ should have kind ‘* -> *’,
      but ‘a’ has kind ‘*’
    In the instance declaration for ‘GDefault (a :+: b)’

我做错了什么?

你不是说...吗?

instance (GDefault a, GDefault b) => GDefault (a :+: b) where ...
  --      ^           ^