小编Vig*_*igo的帖子

非法实例声明

我刚刚用Haskell创建了一个类,但是我的一个实例出了问题.我创建了这个类:

class Symbol a where
  nameSym :: a -> String
Run Code Online (Sandbox Code Playgroud)

和这些实例:

instance Symbol Double where
  nameSym db = show db 

instance Symbol String where
  nameSym str = str
Run Code Online (Sandbox Code Playgroud)

但在编译时,我收到以下错误消息:

Illegal instance declaration for `Symbol String'
  (All instance types must be of the form (T t1 ... tn)
   where T is not a synonym.
In the instance declaration for `Symbol String'
Run Code Online (Sandbox Code Playgroud)

你知道这是什么问题吗?

haskell class instance

2
推荐指数
1
解决办法
512
查看次数

标签 统计

class ×1

haskell ×1

instance ×1