Skip to content

Commit 1931ecf

Browse files
committed
Add an IsList instance for Data.Sequence.Seq
1 parent e1e75b8 commit 1931ecf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Data/Sequence.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#if __GLASGOW_HASKELL__ >= 703
66
{-# LANGUAGE Trustworthy #-}
77
#endif
8+
#if __GLASGOW_HASKELL__ >= 708
9+
{-# LANGUAGE TypeFamilies #-}
10+
#endif
811
-- We use cabal-generated MIN_VERSION_base to adapt to changes of base.
912
-- Nevertheless, as a convenience, we also allow compiling without cabal by
1013
-- defining trivial MIN_VERSION_base if needed.
@@ -171,7 +174,9 @@ import Data.Coerce
171174
#if MIN_VERSION_base(4,8,0)
172175
import Data.Functor.Identity (Identity(..))
173176
#endif
174-
177+
#if __GLASGOW_HASKELL__ >= 708
178+
import qualified GHC.Exts
179+
#endif
175180

176181
infixr 5 `consTree`
177182
infixl 5 `snocTree`
@@ -1655,6 +1660,13 @@ findIndicesR p xs = foldlWithIndex g [] xs
16551660
fromList :: [a] -> Seq a
16561661
fromList = Data.List.foldl' (|>) empty
16571662

1663+
#if __GLASGOW_HASKELL__ >= 708
1664+
instance GHC.Exts.IsList (Seq a) where
1665+
type Item (Seq a) = a
1666+
fromList = fromList
1667+
toList = toList
1668+
#endif
1669+
16581670
------------------------------------------------------------------------
16591671
-- Reverse
16601672
------------------------------------------------------------------------

0 commit comments

Comments
 (0)