Worked further with your lib, and get stucked at the magnitude definition. why don’t use field-axioms for your scalar (eg. by introducing a new class field and/or group..) to have an abstract inverse and so on, to avoid the (Fractional in ^/). Also I miss a “VectorSpace with Norm” and “VectorSpace with Metric”. by using those kind of abstractions you can avoid the “Floating” in “magnitude” and all the definions will be real-generic.

]]>e.g.: [1,1,1] ^+^ [1,1] = [2,2,1]

import Data.VectorSpace instance (AdditiveGroup v) => AdditiveGroup [v] where zeroV = [] v ^+^ u = zipWithDefault (^+^) zeroV zeroV v u negateV v = map negateV v instance (VectorSpace v, s ~ Scalar v) => VectorSpace [v] where type Scalar [v] = Scalar v s *^ v = map (s *^) v instance (InnerSpace v, AdditiveGroup (Scalar v)) => InnerSpace [v] where v <.> u = foldl (^+^) zeroV $ zipWithDefault (<.>) zeroV zeroV v u -- like zipWith(Prelude) but with default values which -- will be used if one list is shorter than the other zipWithDefault :: (a -> b -> c) -> a -> b -> [a] -> [b] -> [c] zipWithDefault z ad bd (a:as) (b:bs) = z a b : zipWithDefault z ad bd as bs zipWithDefault z ad _ [] bs = map (z ad) bs zipWithDefault z _ bd as [] = map ((flip z) bd) as]]>

What do you mean by a canonical basis? A vector space doesn’t have one distinguished basis.

The library distinguishes one basis out of the many possible. I mean a canonical basis in that sense, not universally.

]]>I agree. Thanks for the reminder, Luke. And not just as comments but as executable QuickCheck test generators.

]]>I have a feature request for vector-space. The definition of AdditiveGroup you gave is incomplete; it is missing essential documentation. Please help set the trend and document typeclass laws in plain sight.

]]>