If I have a Traversable
instance, xs
, how do I convert it into a Vector
?
All Traversable
instances are also Foldable
, so you can write something like
toVector :: Foldable t => t a -> Vector a
toVector = Vector.fromList . Foldable.toList
{-# INLINE toVector #-}
This might make an intermediate list though, if that doesn't get fused away. The inlining should help make fusion more likely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With