I've got a question about type classes. I've got the following code:
import Foreign.C.Types (CDouble, CFloat)
class Floating a => Trigonometry a where
versin :: a -> a
versin x = 1 - cos x
vercos :: a -> a
vercos x = 1 + cos x
coversin :: a -> a
coversin x = 1 - sin x
covercos :: a -> a
covercos x = 1 + sin x
haversin :: a -> a
haversin x = versin x * 0.5
havercos :: a -> a
havercos x = vercos x * 0.5
hacoversin :: a -> a
hacoversin x = coversin x * 0.5
hacovercos :: a -> a
hacovercos x = covercos x * 0.5
instance Trigonometry CDouble
instance Trigonometry CFloat
instance Trigonometry Double
instance Trigonometry Float
Now my question is: there can be infinite amount of Floating instances, and obviously every single instance of Floating can be an instance of Trigonometry without extra implementation. Is there a way to avoid the explicit instance declarations at the bottom and automatically make all Floating instances become Trigonometry instance too?
Cheers!