22

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'

1 Answer 1

33

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.