I have these functions in a Haskell file and they work fine :
func1 :: Integer -> (Integer,Integer) -> [[String]] -> ([Char],[Char],[Char],[Char]) -> (Integer,Integer)
func1 distance agent mymap moves = func5 (func3 agent (func2 distance agent mymap) moves)
func2 :: Integer -> (Integer,Integer) -> [[String]] -> [(Integer,Integer)]
func3 :: (Ord a, Ord b) => (b,a) -> [(b,a)] -> ([Char],[Char],[Char],[Char]) -> [(b,a)]
func4 :: (Int,Int) -> (Int,Int) -> ([Char],[Char],[Char],a) -> ([Char],[Char],[Char],[Char]) -> [[[Char]]] -> [[[Char]]]
func5 [(a,b)] = (a,b)
But when I write this function :
func6 agent distance mymap moves moves2 = func4 agent (func1 distance agent mymap moves) moves moves2 mymap
I get this error :
*ERROR "play.hs":176 - Type error in application
* * * Expression : moveWithFood agent (giveNearestCorrect distance agent mymap moves) moves moves2 mymap
* * * Term : giveNearestCorrect distance agent mymap moves
* * * Type : (Integer,Integer)
* * * Does not match : (Int,Int)*
Same error with ghci:
play.hs:176:93:
Couldn't match expected type `Integer' against inferred type `Int'
Expected type: (Integer, Integer)
Inferred type: (Int, Int)
In the second argument of `giveNearestCorrect', namely `agent'
In the second argument of `moveWithFood', namely
`(giveNearestCorrect distance agent mymap moves)'
Failed, modules loaded: none.*
I tried several things to solve it but I couldn't succeed. Can you tell me what I should do? Thanks.
IntegerandIntare not the same type. You may want to pick one and stick with it.Int. Perhaps the sensible thing to do would be to use type synonyms liketype Agent = (Int, Int)and then writeAgentin types whenever you mean anAgent. That'll make it easier to keep your types consistent. Start by rewriting the types in your code so they clearly express what you mean. If there's still a problem with the equations, it should then at least be clearer what's amiss.