Skip to content

Commit c52ac05

Browse files
committed
Improve fromList docs
1 parent 5d4226e commit c52ac05

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

vector/src/Data/Vector.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,13 @@ toList :: Vector a -> [a]
21722172
{-# INLINE toList #-}
21732173
toList = G.toList
21742174

2175-
-- | /O(n)/ Convert a list to a vector.
2175+
-- | /O(n)/ Convert a list to a vector. During the operation, the
2176+
-- vector’s capacity will be doubling until the list's contents are
2177+
-- in the vector. Depending on the list’s size, up to half of the vector’s
2178+
-- capacity might be empty. If you’d rather avoid this, you can use
2179+
-- 'fromListN', which will provide the exact space the list requires but will
2180+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
2181+
-- vector and then copy it without the superfluous space.
21762182
fromList :: [a] -> Vector a
21772183
{-# INLINE fromList #-}
21782184
fromList = G.fromList

vector/src/Data/Vector/Generic.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2364,7 +2364,13 @@ toList :: Vector v a => v a -> [a]
23642364
{-# INLINE toList #-}
23652365
toList = Bundle.toList . stream
23662366

2367-
-- | /O(n)/ Convert a list to a vector.
2367+
-- | /O(n)/ Convert a list to a vector. During the operation, the
2368+
-- vector’s capacity will be doubling until the list's contents are
2369+
-- in the vector. Depending on the list’s size, up to half of the vector’s
2370+
-- capacity might be empty. If you’d rather avoid this, you can use
2371+
-- 'fromListN', which will provide the exact space the list requires but will
2372+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
2373+
-- vector and then copy it without the superfluous space.
23682374
fromList :: Vector v a => [a] -> v a
23692375
{-# INLINE fromList #-}
23702376
fromList = unstream . Bundle.fromList

vector/src/Data/Vector/Primitive.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,13 @@ toList :: Prim a => Vector a -> [a]
18361836
{-# INLINE toList #-}
18371837
toList = G.toList
18381838

1839-
-- | /O(n)/ Convert a list to a vector.
1839+
-- | /O(n)/ Convert a list to a vector. During the operation, the
1840+
-- vector’s capacity will be doubling until the list's contents are
1841+
-- in the vector. Depending on the list’s size, up to half of the vector’s
1842+
-- capacity might be empty. If you’d rather avoid this, you can use
1843+
-- 'fromListN', which will provide the exact space the list requires but will
1844+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
1845+
-- vector and then copy it without the superfluous space.
18401846
fromList :: Prim a => [a] -> Vector a
18411847
{-# INLINE fromList #-}
18421848
fromList = G.fromList

vector/src/Data/Vector/Storable.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,13 @@ toList :: Storable a => Vector a -> [a]
18831883
{-# INLINE toList #-}
18841884
toList = G.toList
18851885

1886-
-- | /O(n)/ Convert a list to a vector.
1886+
-- | /O(n)/ Convert a list to a vector. During the operation, the
1887+
-- vector’s capacity will be doubling until the list's contents are
1888+
-- in the vector. Depending on the list’s size, up to half of the vector’s
1889+
-- capacity might be empty. If you’d rather avoid this, you can use
1890+
-- 'fromListN', which will provide the exact space the list requires but will
1891+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
1892+
-- vector and then copy it without the superfluous space.
18871893
fromList :: Storable a => [a] -> Vector a
18881894
{-# INLINE fromList #-}
18891895
fromList = G.fromList

vector/src/Data/Vector/Strict.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2442,7 +2442,13 @@ toList :: Vector a -> [a]
24422442
{-# INLINE toList #-}
24432443
toList = G.toList
24442444

2445-
-- | /O(n)/ Convert a list to a vector.
2445+
-- | /O(n)/ Convert a list to a vector. During the operation, the
2446+
-- vector’s capacity will be doubling until the list's contents are
2447+
-- in the vector. Depending on the list’s size, up to half of the vector’s
2448+
-- capacity might be empty. If you’d rather avoid this, you can use
2449+
-- 'fromListN', which will provide the exact space the list requires but will
2450+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
2451+
-- vector and then copy it without the superfluous space.
24462452
--
24472453
-- @since 0.13.2.0
24482454
fromList :: [a] -> Vector a

vector/src/Data/Vector/Unboxed.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,13 @@ toList :: Unbox a => Vector a -> [a]
19281928
{-# INLINE toList #-}
19291929
toList = G.toList
19301930

1931-
-- | /O(n)/ Convert a list to a vector.
1931+
-- | /O(n)/ Convert a list to a vector. During the operation, the
1932+
-- vector’s capacity will be doubling until the list's contents are
1933+
-- in the vector. Depending on the list’s size, up to half of the vector’s
1934+
-- capacity might be empty. If you’d rather avoid this, you can use
1935+
-- 'fromListN', which will provide the exact space the list requires but will
1936+
-- prevent list fusion, or @'force' . 'fromList'@, which will create the
1937+
-- vector and then copy it without the superfluous space.
19321938
fromList :: Unbox a => [a] -> Vector a
19331939
{-# INLINE fromList #-}
19341940
fromList = G.fromList

0 commit comments

Comments
 (0)