2016-05-16 12 views
0

私はハスケルを学んでいます。予想されるタイプに一致しませんでした

次のコードは、任意の助けをいただければ幸いです

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.

をコンパイルされていません。

答えて

1

クラスとインスタンス宣言は、その有する機能のためのスペースが必要になります。

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

関連する問題