I have the following type class
class MyClass c where
aFunction :: c -> Bool
and two instances for two different data types
data MyDataType1 = MyDataType1
instance MyClass MyDataType1 where
aFunction c = True
data MyDataType2 = MyDataType2
instance MyClass MyDataType2 where
aFunction c = False
I want to write a function a function which takes two parameters of typeclass MyClass (which might be the same data type or might be different and returns one of them. I'm struggling to work out the type signature for this and I think I might be taking the wrong approach.
Would this be correct? If not what should I use instead?
chooseOne :: (MyClass a, MyClass b) => a -> b -> ?
chooseOne x y = if (aFunction x) then x else y