purescript-fast-vect
purescript-fast-vect copied to clipboard
`Vect` to nested tuple conversion
Hi, thanks a lot for building this lib! :-)
I find it useful to be able to deconstruct a Vect i a value into a tuple. I mean:
a /\ b /\ c = vectTuple $ 1 : 2 : 3 : empty
Do you think it would be valuable addition?
P.S. I'm using this class to handle this - so this is my possible upcoming PR:
class VectTuple vect tuple | vect -> tuple where
vectTuple :: vect -> tuple
instance VectTuple (Vect 1 a) a where
vectTuple vect = head vect
else instance
( Add 1 i' i
, VectTuple (Vect i' a) tpl
, Compare i' NegOne GT
, Compare i NegOne GT
, Compare i 0 GT
) =>
VectTuple (Vect i a) (a /\ tpl) where
vectTuple vect = head vect /\ vectTuple ((drop (Proxy :: Proxy 1) vect) :: Vect i' a)
I see no reason why not. The only thing may be that it is probably only really usable for small vectors, but I guess this could be a comment
Yeah, looks good to me too