I have made a type class and made list an instance of type class but I am getting an error which I do not understand
class MyType a where
listsum:: a->a->Double
instance (Num a)=>MyType [a] where
listsum x y = sum $ zipWith (-) x y
listsum returns a single value but this is the error I get:
Could not deduce (a ~ Double)
from the context (Num a)
bound by the instance declaration at b2.hs:4:10-28
`a' is a rigid type variable bound by
the instance declaration at b2.hs:4:10
In the expression: sum $ zipWith (-) x y
In an equation for `listsum': listsum x y = sum $ zipWith (-) x y
In the instance declaration for `MyType [a]'
Failed, modules loaded: none.
How do I solve this?