Type design question

Andrew J Bromage ajb@spamcop.net
Mon, 28 Jul 2003 11:59:48 +1000


G'day all.

On Fri, Jul 25, 2003 at 03:48:15PM -0400, Dylan Thurston wrote:

> Another approach is to make Universe a multi-parameter type class:
> 
> class (RealFrac a, Floating a) => Universe u a | u -> a where
>   distanceVector :: u -> Vector a -> Vector a -> Vector a
> ...

Actually, this is a nice way to represent vector spaces, too:

	class (Num v, Fractional f) => VectorSpace vs v f | vs -> v f where
	    scale :: vs -> f -> v -> v
	    innerProduct :: vs -> v -> v -> f

The reason why you may want to do this is that you may in general want
different inner products on the same vectors, which result in different
vector spaces.

Cheers,
Andrew Bromage