Skip to content

Commit 9b37d5a

Browse files
committed
Use coerce for [a]->[Elem a] convertion in fromList.
1 parent a1d613b commit 9b37d5a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Data/Sequence.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ findIndicesR p xs = foldlWithIndex g [] xs
17591759
-- There is a function 'toList' in the opposite direction for all
17601760
-- instances of the 'Foldable' class, including 'Seq'.
17611761
fromList :: [a] -> Seq a
1762-
fromList xs = Seq $ mkTree 1 $ Data.List.map Elem xs
1762+
fromList xs = Seq $ mkTree 1 $ map_elem xs
17631763
where
17641764
{-# SPECIALIZE mkTree :: Int -> [Elem a] -> FingerTree (Elem a) #-}
17651765
{-# SPECIALIZE mkTree :: Int -> [Node a] -> FingerTree (Node a) #-}
@@ -1781,6 +1781,14 @@ fromList xs = Seq $ mkTree 1 $ Data.List.map Elem xs
17811781
getNodes s (x1:x2:x3:xs) = s `seq` (Node3 s x1 x2 x3:ns, d)
17821782
where (ns, d) = getNodes s xs
17831783

1784+
map_elem :: [a] -> [Elem a]
1785+
#if __GLASGOW_HASKELL__ >= 708
1786+
map_elem xs = coerce xs
1787+
#else
1788+
map_elem xs = Data.List.map Elem xs
1789+
#endif
1790+
{-# INLINE map_elem #-}
1791+
17841792
#if __GLASGOW_HASKELL__ >= 708
17851793
instance GHC.Exts.IsList (Seq a) where
17861794
type Item (Seq a) = a

0 commit comments

Comments
 (0)