Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个Traversable实例,xs如何将其转换为Vector?
Traversable
xs
Vector
所有Traversable实例也是Foldable,所以你可以写类似
Foldable
toVector :: Foldable t => t a -> Vector a toVector = Vector.fromList . Foldable.toList {-# INLINE toVector #-}
不过,如果没有融合,这可能会成为一个中间列表。内联应该有助于使融合更有可能。