[commit: packages/containers] cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, revert-408-bugfix_394: Add lifted instances for Data.Sequence (c25272e)
git at git.haskell.org
git at git.haskell.org
Mon Apr 17 21:46:25 UTC 2017
Repository : ssh://git@git.haskell.org/containers
On branches: cleaned_bugfix394,master,merge-doc-target,merge-fixes-5.9,revert-408-bugfix_394
Link : http://git.haskell.org/packages/containers.git/commitdiff/c25272e0c58bfa2b6deaa90cb24c4ab4565ad901
>---------------------------------------------------------------
commit c25272e0c58bfa2b6deaa90cb24c4ab4565ad901
Author: David Feuer <David.Feuer at gmail.com>
Date: Tue Dec 13 12:50:57 2016 -0500
Add lifted instances for Data.Sequence
Add instances of `Eq1`, `Ord1`, `Show1`, and `Read1` for
`Data.Sequence`.
>---------------------------------------------------------------
c25272e0c58bfa2b6deaa90cb24c4ab4565ad901
Data/Sequence/Internal.hs | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/Data/Sequence/Internal.hs b/Data/Sequence/Internal.hs
index 9cacb39..d2bfa04 100644
--- a/Data/Sequence/Internal.hs
+++ b/Data/Sequence/Internal.hs
@@ -213,6 +213,7 @@ import Data.Foldable (Foldable(foldl, foldl1, foldr, foldr1, foldMap), foldl', t
#if MIN_VERSION_base(4,9,0)
import qualified Data.Semigroup as Semigroup
+import Data.Functor.Classes
#endif
import Data.Traversable
import Data.Typeable
@@ -703,6 +704,18 @@ instance Show a => Show (Seq a) where
showString "fromList " . shows (toList xs)
#endif
+#if MIN_VERSION_base(4,9,0)
+instance Show1 Seq where
+ liftShowsPrec _shwsPrc shwList p xs = showParen (p > 10) $
+ showString "fromList " . shwList (toList xs)
+
+instance Eq1 Seq where
+ liftEq eq xs ys = length xs == length ys && liftEq eq (toList xs) (toList ys)
+
+instance Ord1 Seq where
+ liftCompare cmp xs ys = liftCompare cmp (toList xs) (toList ys)
+#endif
+
instance Read a => Read (Seq a) where
#ifdef __GLASGOW_HASKELL__
readPrec = parens $ prec 10 $ do
@@ -718,6 +731,14 @@ instance Read a => Read (Seq a) where
return (fromList xs,t)
#endif
+#if MIN_VERSION_base(4,9,0)
+instance Read1 Seq where
+ liftReadsPrec _rp readLst p = readParen (p > 10) $ \r -> do
+ ("fromList",s) <- lex r
+ (xs,t) <- readLst s
+ pure (fromList xs, t)
+#endif
+
instance Monoid (Seq a) where
mempty = empty
mappend = (><)
More information about the ghc-commits
mailing list