-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ord instances for Interval, IntervalSet and IntervalMap #41
Conversation
I'm generally in favor of this. @msakai what do you think? |
ping @msakai, should I put in the effort to get CI cleaned up for all versions on this, or is this patch undesirable overall? |
Sorry for the delay. I will take a look. |
It is a bit unnatural, just like defining |
@googleson78 diff --git a/src/Data/Interval/Internal.hs b/src/Data/Interval/Internal.hs
index 16890a4..ae26189 100644
--- a/src/Data/Interval/Internal.hs
+++ b/src/Data/Interval/Internal.hs
@@ -56,12 +56,12 @@ data Interval r
| RightOpen !r !r
| BothOpen !r !r
deriving
- ( Eq,
- Ord,
+ ( Eq
+ , Ord
-- ^ Note that this Ord is derived and not semantically meaningful.
-- The primary intended use case is to allow using 'Interval'
-- in maps and sets that require ordering.
- Typeable
+ , Typeable
)
peekInterval :: (Applicative m, Monad m, Ord r) => m Int8 -> m r -> m r -> m (Interval r)
diff --git a/src/Data/IntervalMap/Base.hs b/src/Data/IntervalMap/Base.hs
index 556e763..f8a4979 100644
--- a/src/Data/IntervalMap/Base.hs
+++ b/src/Data/IntervalMap/Base.hs
@@ -124,12 +124,12 @@ import qualified GHC.Exts as GHCExts
-- even if adjacent intervals are connected and mapped to the same value.
newtype IntervalMap r a = IntervalMap (Map (LB r) (Interval r, a))
deriving
- ( Eq,
- Ord,
+ ( Eq
+ , Ord
-- ^ Note that this Ord is derived and not semantically meaningful.
-- The primary intended use case is to allow using 'IntervalSet'
-- in maps and sets that require ordering.
- Typeable
+ , Typeable
)
#if __GLASGOW_HASKELL__ >= 708
diff --git a/src/Data/IntervalSet.hs b/src/Data/IntervalSet.hs
index 7e44647..fac557e 100644
--- a/src/Data/IntervalSet.hs
+++ b/src/Data/IntervalSet.hs
@@ -89,12 +89,12 @@ import qualified GHC.Exts as GHCExts
-- Any connected intervals are merged together, and empty intervals are ignored.
newtype IntervalSet r = IntervalSet (Map (Extended r) (Interval r))
deriving
- ( Eq,
- Ord,
+ ( Eq
+ , Ord
-- ^ Note that this Ord is derived and not semantically meaningful.
-- The primary intended use case is to allow using 'IntervalSet'
-- in maps and sets that require ordering.
- Typeable
+ , Typeable
)
#if __GLASGOW_HASKELL__ >= 708 It seems the feature for writing comments in this location was added in GHC 8.2.1. I think it's okay to drop support for GHC <8.2. (We can update the build matrix in a separate PR) |
Dropped support of GHC < 8.2 in 4115223. @googleson78 could you please rebase and try to fix haddocks as suggested? |
The primary intended use case for these is to allow storage in maps and sets.
901b42e
to
9b1cfd0
Compare
Added Masahiro's patch and rebased on master, 🤞 |
Thanks! |
Thanks to the both of you too! |
The primary intended use case for these is to allow storage in maps and sets.