diff options
Diffstat (limited to 'src/Data/Array/Nested/Internal/Ranked.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Ranked.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs index c501015..cb8aae0 100644 --- a/src/Data/Array/Nested/Internal/Ranked.hs +++ b/src/Data/Array/Nested/Internal/Ranked.hs @@ -65,9 +65,17 @@ deriving instance Eq (Mixed (Replicate n Nothing) a) => Eq (Ranked n a) deriving instance Ord (Mixed (Replicate n Nothing) a) => Ord (Ranked n a) instance (Show a, Elt a) => Show (Ranked n a) where - showsPrec d arr = showParen (d > 10) $ - showString "rfromListLinear " . shows (toList (rshape arr)) . showString " " - . shows (rtoListLinear arr) + showsPrec d arr@(Ranked marr) = showParen (d > 10) $ + let defaultResult = + showString "rfromListLinear " . shows (toList (rshape arr)) . showString " " + . shows (rtoListLinear arr) + in if stridesAreZero (shxLength $ mshape marr) (mstrideTree marr) + then case rtoListLinear arr of + [] -> defaultResult + [_] -> defaultResult + hd : _ -> showString "rreplicate " . shows (toList (rshape arr)) . showString " " + . showsPrec 11 hd + else defaultResult instance Elt a => NFData (Ranked n a) where rnf (Ranked arr) = rnf arr |