无法匹配预期类型

问题描述:

我正在学习Haskell。无法匹配预期类型

下面的代码不编译

data Player = Max | Min 
    deriving (Show,Eq) 

class Position a where 
score :: a -> Int 
player :: a -> Player 


data Nim = Nim { turn :: Player, count :: Int} 

instance Position Nim where 
score a = count a 
player a = turn a 

error: Could not match expected type Nim with actual type 'a'. 'a' is a rigid type variable bound by the input signature for player :: a -> Player.

任何帮助,将不胜感激。

的类和实例声明需要间距为他们的职能包括:

class Position a where 
    score :: a -> Int 
    player :: a -> Player 

instance Position Nim where 
    score a = count a 
    player a = turn a 
+0

现在编译OK。谢谢你的帮助。 – user6340505

+0

非常感谢 – user6340505