diff options
Diffstat (limited to 'src/Data/Array/Nested/Internal/Shaped.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Shaped.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Internal/Shaped.hs b/src/Data/Array/Nested/Internal/Shaped.hs index eebf66a..d5c9612 100644 --- a/src/Data/Array/Nested/Internal/Shaped.hs +++ b/src/Data/Array/Nested/Internal/Shaped.hs @@ -66,9 +66,17 @@ deriving instance Eq (Mixed (MapJust sh) a) => Eq (Shaped sh a) deriving instance Ord (Mixed (MapJust sh) a) => Ord (Shaped sh a) instance (Show a, Elt a) => Show (Shaped sh a) where - showsPrec d arr = showParen (d > 10) $ - showString "sfromListLinear " . shows (shsToList (sshape arr)) . showString " " - . shows (stoListLinear arr) + showsPrec d arr@(Shaped marr) = showParen (d > 10) $ + let defaultResult = + showString "sfromListLinear " . shows (shsToList (sshape arr)) . showString " " + . shows (stoListLinear arr) + in if stridesAreZero (shxLength $ mshape marr) (mstrideTree marr) + then case stoListLinear arr of + [] -> defaultResult + [_] -> defaultResult + hd : _ -> showString "sreplicate " . shows (shsToList (sshape arr)) . showString " " + . showsPrec 11 hd + else defaultResult instance Elt a => NFData (Shaped sh a) where rnf (Shaped arr) = rnf arr |