我刚刚用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)
你知道这是什么问题吗?