I'm attempting to add two polymorphic tuples together in a pairwise manner. (The types of the first element in one tuple should be the same as the first in the second and likewise for the second element) Here's my code:
module Main where
class Coordinate a where
createCoordinate :: a
getFirst :: (a,b) -> a
getSecond :: (a,b) -> b
addCoordinates :: (a,b) -> (a,b) -> (a,b)
instance Coordinate () where
createCoordinate = ()
getFirst (a,b) = a
getSecond (a,b) = b
addCoordinates a b = (getFirst a + getFirst b, getSecond a + getSecond b)
So, the problem is with my addCoordinates function. I was wondering if anyone could offer me any help with how to go about implementing the function. Thanks! :)