Reputation: 552
I'm getting the Illegal type signature in instance declaration error and I have no idea why it is popping up for my program. Indentation seems right, etc. I hope you can help me.
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
The error is :
Illegal type signature in instance declaration:
findPossibleMoves :: Player -> HForest -> [(HStrategy, HForest)]
(Use InstanceSigs to allow this)
In the instance declaration for `Game HForest HStrategy'
Upvotes: 22
Views: 8226
Reputation: 14999
You have a type signature in an instance declaration. That's illegal in standard Haskell. You can enable the InstanceSigs
extension (put {-# LANGUAGE InstanceSigs #-}
at the top of your file) to allow it. Or just delete the type signature.
Upvotes: 33