相关疑难解决方法(0)

如何在Haskell中正确实例化类?

试图创建一个基类,我可以从中派生出不同的类型.以下是什么问题?

class (Eq a) => MyClass a 

data Alpha = Alpha
instance MyClass Alpha where
    Alpha == Alpha = True
Run Code Online (Sandbox Code Playgroud)

我收到错误:

test.hs:5:10: `==' is not a (visible) method of class `MyClass'
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)

haskell typeclass

4
推荐指数
1
解决办法
3732
查看次数

标签 统计

haskell ×1

typeclass ×1