@@ -88,7 +88,7 @@ import qualified Streamly.Streams.StreamK as K
89-- @since 0.5.3
89-- @since 0.5.3
90newtype List a = List { toSerial :: SerialT Identity a }
90newtype List a = List { toSerial :: SerialT Identity a }
91− deriving (Show, Read, Eq, Ord, IsList, NFData, NFData1
91+ deriving (Show, Read, Eq, Ord, NFData, NFData1
92 , Semigroup, Monoid, Functor, Foldable
92 , Semigroup, Monoid, Functor, Foldable
93 , Applicative, Traversable, Monad)
93 , Applicative, Traversable, Monad)
@@ -96,6 +96,14 @@ instance (a ~ Char) => IsString (List a) where
96 {-# INLINE fromString #-}
96 {-# INLINE fromString #-}
97 fromString = List . P.fromList
97 fromString = List . P.fromList
99+-- GHC versions 8.0 and below cannot derive IsList
100+instance IsList (List a) where
101+ type (Item (List a)) = a
102+ {-# INLINE fromList #-}
103+ fromList = List . P.fromList
104+ {-# INLINE toList #-}
105+ toList = runIdentity . P.toList . toSerial
99------------------------------------------------------------------------------
107------------------------------------------------------------------------------
100-- Patterns
108-- Patterns
101------------------------------------------------------------------------------
109------------------------------------------------------------------------------
@@ -120,7 +128,9 @@ pattern Cons x xs <-
120 -> Just (x, xs)) where
128 -> Just (x, xs)) where
121 Cons x xs = List $ K.cons x (toSerial xs)
129 Cons x xs = List $ K.cons x (toSerial xs)
131+#if __GLASGOW_HASKELL__ >= 802
123{-# COMPLETE Nil, Cons #-}
132{-# COMPLETE Nil, Cons #-}
125------------------------------------------------------------------------------
135------------------------------------------------------------------------------
126-- ZipList
136-- ZipList
@@ -131,13 +141,22 @@ pattern Cons x xs <-
132-- @since 0.5.3
142-- @since 0.5.3
133newtype ZipList a = ZipList { toZipSerial :: ZipSerialM Identity a }
143newtype ZipList a = ZipList { toZipSerial :: ZipSerialM Identity a }
134− deriving (Show, Read, Eq, Ord, IsList, NFData, NFData1
144+ deriving (Show, Read, Eq, Ord, NFData, NFData1
135− , Semigroup, Monoid, Functor, Applicative, Foldable)
145+ , Semigroup, Monoid, Functor, Foldable
146+ , Applicative, Traversable)
137instance (a ~ Char) => IsString (ZipList a) where
148instance (a ~ Char) => IsString (ZipList a) where
138 {-# INLINE fromString #-}
149 {-# INLINE fromString #-}
139 fromString = ZipList . P.fromList
150 fromString = ZipList . P.fromList
152+-- GHC versions 8.0 and below cannot derive IsList
153+instance IsList (ZipList a) where
154+ type (Item (ZipList a)) = a
155+ {-# INLINE fromList #-}
156+ fromList = ZipList . P.fromList
157+ {-# INLINE toList #-}
158+ toList = runIdentity . P.toList . toZipSerial
141-- | Convert a 'ZipList' to a regular 'List'
160-- | Convert a 'ZipList' to a regular 'List'
143-- @since 0.5.3
162-- @since 0.5.3