From 40022f56cfcf79d56abecf4055d9a5cc3a07447e Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 21 May 2024 11:50:39 +0200 Subject: Add Ord instances on 0-dimensional arrays This is very conservative; of course a law-abiding Ord instance can be defined on full multi-dimensional arrays, but such an instance would be lexicographical (anything else is even stranger), and that is potentially unexpected and definitely does not play well with the other numeric classes. --- src/Data/Array/Mixed.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Data/Array/Mixed.hs') diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs index 320a393..baa9575 100644 --- a/src/Data/Array/Mixed.hs +++ b/src/Data/Array/Mixed.hs @@ -289,6 +289,9 @@ type XArray :: [Maybe Nat] -> Type -> Type newtype XArray sh a = XArray (S.Array (Rank sh) a) deriving (Show, Eq) +-- | Only on scalars, because lexicographical ordering is strange on multi-dimensional arrays. +deriving instance (Ord a, Storable a) => Ord (XArray '[] a) + zeroIxX :: StaticShX sh -> IIxX sh zeroIxX ZKX = ZIX zeroIxX (_ :!% ssh) = 0 :.% zeroIxX ssh -- cgit v1.2.3-70-g09d2