From 4def20b2699f8268ba7d03f3a228273ff613dc0d Mon Sep 17 00:00:00 2001 From: Mikolaj Konarski Date: Sun, 21 Apr 2024 23:13:42 +0200 Subject: Derive also the Ord instance for sized lists --- src/Data/Array/Mixed.hs | 1 + src/Data/Array/Nested/Internal.hs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Data/Array') diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs index 8b90547..47027cb 100644 --- a/src/Data/Array/Mixed.hs +++ b/src/Data/Array/Mixed.hs @@ -54,6 +54,7 @@ data IxX sh i where (:.?) :: forall sh i. i -> IxX sh i -> IxX (Nothing : sh) i deriving instance Show i => Show (IxX sh i) deriving instance Eq i => Eq (IxX sh i) +deriving instance Ord i => Ord (IxX sh i) infixr 3 :.@ infixr 3 :.? diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index b758e55..4dc39c3 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -858,6 +858,7 @@ data ListR n i where (:::) :: forall n i. i -> ListR n i -> ListR (S n) i deriving instance Show i => Show (ListR n i) deriving instance Eq i => Eq (ListR n i) +deriving instance Ord i => Ord (ListR n i) infixr 3 ::: deriving stock instance Functor (ListR n) @@ -872,7 +873,7 @@ listRToList (i ::: is) = i : listRToList is -- | An index into a rank-typed array. type IxR :: INat -> Type -> Type newtype IxR n i = IxR (ListR n i) - deriving (Show, Eq) + deriving (Show, Eq, Ord) deriving newtype instance Functor (IxR n) @@ -902,7 +903,7 @@ type IIxR n = IxR n Int type StaticShapeR :: INat -> Type -> Type newtype StaticShapeR n i = StaticShapeR (ListR n i) - deriving (Show, Eq) + deriving (Show, Eq, Ord) deriving newtype instance Functor (StaticShapeR n) @@ -1070,6 +1071,7 @@ data ListS sh i where (::$) :: forall n sh i. i -> ListS sh i -> ListS (n : sh) i deriving instance Show i => Show (ListS sh i) deriving instance Eq i => Eq (ListS sh i) +deriving instance Ord i => Ord (ListS sh i) infixr 3 ::$ deriving stock instance Functor (ListS sh) @@ -1089,7 +1091,7 @@ listSToList (i ::$ is) = i : listSToList is -- from a 'KnownShape' dictionary. type IxS :: [Nat] -> Type -> Type newtype IxS sh i = IxS (ListS sh i) - deriving (Show, Eq) + deriving (Show, Eq, Ord) deriving newtype instance Functor (IxS sh) @@ -1119,7 +1121,7 @@ type IIxS sh = IxS sh Int type StaticShapeS :: [Nat] -> Type -> Type newtype StaticShapeS sh i = StaticShapeS (ListS sh i) - deriving (Show, Eq) + deriving (Show, Eq, Ord) deriving newtype instance Functor (StaticShapeS sh) -- cgit v1.2.3-70-g09d2