我在实例声明错误中收到非法类型签名,我不知道为什么它会弹出我的程序。缩进似乎是对的,等等。 我希望你能帮助我。
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'
答案 0 :(得分:11)
您在实例声明中有一个类型签名。这在标准的Haskell中是非法的。您可以启用InstanceSigs
扩展名(将{-# LANGUAGE InstanceSigs #-}
放在文件顶部)以允许它。或者只是删除类型签名。