diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-05-21 11:50:39 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-05-21 11:50:47 +0200 |
commit | 40022f56cfcf79d56abecf4055d9a5cc3a07447e (patch) | |
tree | d278b3d0ee91e096f3568b3c17b17108813f2b06 /src/Data/Array/Mixed.hs | |
parent | 3d2e4a567668ea951e629834e6871a3f144c1b84 (diff) |
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.
Diffstat (limited to 'src/Data/Array/Mixed.hs')
-rw-r--r-- | src/Data/Array/Mixed.hs | 3 |
1 files changed, 3 insertions, 0 deletions
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 |