Dav*_*vid 11

所有Traversable实例也都是Foldable,所以你可以写类似的东西

toVector :: Foldable t => t a -> Vector a
toVector = Vector.fromList . Foldable.toList
{-# INLINE toVector #-}
Run Code Online (Sandbox Code Playgroud)

这可能会成为一个中间列表,如果这不会被融合掉.内联应该有助于使融合更有可能.