aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Mixed
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2025-12-01 17:15:05 +0100
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2025-12-01 17:15:05 +0100
commit0028b655341069e83db6e0bfde01dea1c696f5aa (patch)
treed43e18d574654043b81ccfaaa3c9ae9e7784dc91 /src/Data/Array/Nested/Mixed
parent9560d0f26420409afd2230fb7e5e111eafcced06 (diff)
Unify toList functions for shapes
Diffstat (limited to 'src/Data/Array/Nested/Mixed')
-rw-r--r--src/Data/Array/Nested/Mixed/Shape.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape.hs b/src/Data/Array/Nested/Mixed/Shape.hs
index a9ed2d0..4626481 100644
--- a/src/Data/Array/Nested/Mixed/Shape.hs
+++ b/src/Data/Array/Nested/Mixed/Shape.hs
@@ -140,6 +140,7 @@ listxFromList topssh topl = go topssh topl
++ show (ssxLength topssh) ++ ", list has length "
++ show (length topl) ++ ")"
+{-# INLINEABLE listxToList #-}
listxToList :: ListX sh' (Const i) -> [i]
listxToList ZX = []
listxToList (Const i ::% is) = i : listxToList is
@@ -219,6 +220,9 @@ instance Foldable (IxX sh) where
{-# INLINE foldr #-}
foldr _ z ZIX = z
foldr f z (x :.% xs) = f x (foldr f z xs)
+ {-# INLINEABLE toList #-}
+ toList ZIX = []
+ toList (i :.% is) = i : Foldable.toList is
null ZIX = False
null _ = True
@@ -441,6 +445,7 @@ shxFromList topssh topl = go topssh topl
++ show (ssxLength topssh) ++ ", list has length "
++ show (length topl) ++ ")"
+{-# INLINEABLE shxToList #-}
shxToList :: IShX sh -> [Int]
shxToList ZSX = []
shxToList (smn :$% sh) = fromSMayNat' smn : shxToList sh