This is a follow up question to this question. Somebody suggested there that it would make more sense to make the type network an instance of vectorSpace.
newtype Network = Network [( Matrix Double, Vector Double)]
instance AdditiveGroup Network where
(Network n1) ^+^ (Network n2) = Network $ zipWith (\(m,v) (n,w) -> (m+n,v+w)) n1 n2
(Network n1) ^-^ (Network n2) = Network $ zipWith (\(m,v) (n,w) -> (m-n,v-w)) n1 n2
instance VectorSpace Network where
type Scalar Network = Double
lambda *^ (Network n) = Network $ map (\ (m,v) -> (lambda*m,lambda*v)) n
But when I try to compile I get an error saying that i wrote an illegal instance for 'Scalar'. Could somebody explain me what I did wrong?