On Monday 18 August 2003 09:25, Bernard James POPE wrote:

> The kinds are there to help the compiler check whether types are well
> formed (including such things as instance declarations).
>
> The syntax for kinds is very simple:
...

Thanks for the explanation! It seems that what I need (but what apparently 
doesn't exist) is the equivalent of a lambda expression for type 
constructors, then I could write something like

instance Vect (\a -> [Vector a]) a where
...

> One way around this might be to define a new type:
>
>    newtype ListVector a = LV [Vector a]
>
>    instance Vect ListVector a where
>      (<+>) (LV l1) (LV l2) = LV $ zipWith (<+>) l1 l2
>
> Though is is bit ugly to have to mention the LV constructor all the time.

It's not just ugly, it destroys the generality of my code. I would like to be 
able to have generic list processing functions (think of "map") produce lists 
of vectors and then be able to apply the functions in class "Vect" to them. 
If I introduce a new type, then I will have to put wrapper functions in many 
places. I really want a type that is a list *and* an instance of class Vect.

In fact, what I'd really like to have is even more general:

instance Vect v a => Vect [Vect v a] where
...

i.e. defining that a list of any Vect instance is itself a Vect instance. But 
I could live with the case that I presented initially.

Konrad.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to