[英]Wrong argument kind when using GHC Generics
I've been following the GHC.Generics tutorial to make a simple generic typeclass for providing default values for arbitrary types. 我一直在遵循GHC.Generics教程来制作一个简单的泛型类型类,以为任意类型提供默认值。 However when I try to load my file (relevant snippet, which still produces the error)
但是,当我尝试加载文件时(相关代码段仍会产生错误)
{-# 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
I get the following error: 我收到以下错误:
Generic.hs:12:46:
The first argument of ‘:+:’ should have kind ‘* -> *’,
but ‘a’ has kind ‘*’
In the instance declaration for ‘GDefault (a :+: b)’
What am I doing wrong? 我究竟做错了什么?
Don't you mean...? 你不是说...吗?
instance (GDefault a, GDefault b) => GDefault (a :+: b) where ...
-- ^ ^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.