class (Ord st) => MinimaxState st where successors:: st -> [(action,st)] terminal:: st -> Bool
A trivial example would be:
instance MinimaxState Int where terminal i = i == 0 successors i = [(1,i+1), (-1,i-1)]
However, I get this error in GHC:
Could not deduce (Num action)
from the context (MinimaxState Int, Ord Int)
arising from the literal `1' at AbTest.hs:7
Probable fix:
Add (Num action) to the class or instance method `successors'
In the first argument of `negate', namely `1'
In the list element: (- 1, (- i) - 1)
In the definition of `successors':
successors i = [(1, i + 1), (- 1, (- i) - 1)]I have the class definition and the instance definition in seperate files. I don't understand where I'm supposed to put the "probable fix." I don't want it to be in the class definition, since action should be fairly arbitrary.
In fact, no matter what I try, I get errors, for example:
instance MinimaxState Int where
terminal i = i == 0
successors i = [("action",i+1), ("action",i-1)] Cannot unify the type-signature variable `action'
with the type `[Char]'
Expected type: action
Inferred type: [Char]
In the list element: ("action", i + 1)
In the definition of `successors':
successors i = [("action", i + 1), ("action", (- i) - 1)]Any suggestions?
-Arjun _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
