Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
下面的haskell typeclass实例有什么问题?_Haskell_Typeclass - Fatal编程技术网

下面的haskell typeclass实例有什么问题?

下面的haskell typeclass实例有什么问题?,haskell,typeclass,Haskell,Typeclass,showt.hs:3:2:show'不是类的(可见)方法II'实例声明中的类名称应位于类型之前。您还需要删除派生子句,因为您提供的是自己的实例,而不是使用自动派生的实例。您还需要在show的单个参数周围添加括号,否则解析器会看到3个参数 data II = I Int Int deriving (Show) instance II Show where show I a b = show (a+b) data II = I Int Int instance Show II where

showt.hs:3:2:
show'不是类的(可见)方法
II'

实例声明中的类名称应位于类型之前。您还需要删除
派生
子句,因为您提供的是自己的实例,而不是使用自动派生的实例。您还需要在
show
的单个参数周围添加括号,否则解析器会看到3个参数

data II = I Int Int deriving (Show)
instance II Show where
  show I a b = show (a+b)
data II = I Int Int
instance Show II where
    show (I a b) = show (a+b)