实例声明中的非法类型签名

Illegal type signature in instance declaration

我在实例声明错误中收到非法类型签名,我不知道为什么它会在我的程序中弹出。缩进似乎是正确的,等等。 我希望你能帮助我。

class Game g s | g -> s where
  findPossibleMoves :: Player -> g -> [(s,g)]
  identifyWinner :: g -> Player -> Maybe Player

instance Game HForest HStrategy where
  identifyWinner :: HForest -> Player -> Maybe Player
  identifyWinner ts p = getWinner $ getLeaves ts

  findPossibleMoves :: Player -> HForest -> [(HStrategy, HForest)]
  findPossibleMoves p ts = map (\s -> (s,move s ts)) $ getStrategies p ts

错误是:

Illegal type signature in instance declaration:
  findPossibleMoves :: Player -> HForest -> [(HStrategy, HForest)]
(Use InstanceSigs to allow this)
In the instance declaration for `Game HForest HStrategy'

您在实例声明中有类型签名。这在标准 Haskell 中是非法的。您可以启用 InstanceSigs 扩展名(将 {-# LANGUAGE InstanceSigs #-} 放在文件顶部)以允许它。或者只删除类型签名。