Re: [Haskell-cafe] Context for type parameters of type constructors

Could not deduce (Num a) from the context (VectorSpace VList)
The problem is in the definition: zero = VList (repeat 0) Is "0" an Int or an Integer? To define zero, instances need to be parameterised by vector type: EG: class VectorSpace v a where zero :: v a add :: v a -> v a -> v a scale :: a -> v a -> v a instance VectorSpace VList Int where zero = VList (repeat 0) ... instance VectorSpace VList Float where zero = VList (repeat 0.0) etc...
Could not deduce (Num a) from the context (VectorSpace VList)
The problem is in the definition: zero = VList (repeat 0) Is "0" an Int or an Integer? To define zero, instances need to be parameterised by vector type: EG: class VectorSpace v a where zero :: v a add :: v a -> v a -> v a scale :: a -> v a -> v a instance VectorSpace VList Int where zero = VList (repeat 0) ... instance VectorSpace VList Float where zero = VList (repeat 0.0) etc... Regards, Keean.
participants (1)
-
MR K P SCHUPKE