[commit: packages/containers] cleaned_bugfix394, master, merge-doc-target, merge-fixes-5.9, revert-408-bugfix_394: Add instances for Data.Set (0063b9a)

git at git.haskell.org git at git.haskell.org
Mon Apr 17 21:46:29 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/0063b9aa8b371f0eb00c9357bdd55b7ceb0a0a4c

>---------------------------------------------------------------

commit 0063b9aa8b371f0eb00c9357bdd55b7ceb0a0a4c
Author: Oleg Grenrus <oleg.grenrus at iki.fi>
Date:   Tue Dec 13 20:43:15 2016 -0500

    Add instances for Data.Set
    
    Add `Eq1`, `Ord1`, and `Show1` instances for `Data.Set`.


>---------------------------------------------------------------

0063b9aa8b371f0eb00c9357bdd55b7ceb0a0a4c
 Data/Set/Internal.hs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/Data/Set/Internal.hs b/Data/Set/Internal.hs
index fa00711..e3eea79 100644
--- a/Data/Set/Internal.hs
+++ b/Data/Set/Internal.hs
@@ -229,6 +229,7 @@ import Data.Monoid (Monoid(..))
 #endif
 #if MIN_VERSION_base(4,9,0)
 import Data.Semigroup (Semigroup((<>), stimes), stimesIdempotentMonoid)
+import Data.Functor.Classes
 #endif
 import qualified Data.Foldable as Foldable
 import Data.Typeable
@@ -1061,6 +1062,20 @@ instance Show a => Show (Set a) where
   showsPrec p xs = showParen (p > 10) $
     showString "fromList " . shows (toList xs)
 
+#if MIN_VERSION_base(4,9,0)
+instance Eq1 Set where
+    liftEq eq m n =
+        size m == size n && liftEq eq (toList m) (toList n)
+
+instance Ord1 Set where
+    liftCompare cmp m n =
+        liftCompare cmp (toList m) (toList n)
+
+instance Show1 Set where
+    liftShowsPrec sp sl d m =
+        showsUnaryWith (liftShowsPrec sp sl) "fromList" d (toList m)
+#endif
+
 {--------------------------------------------------------------------
   Read
 --------------------------------------------------------------------}



More information about the ghc-commits mailing list