summaryrefslogtreecommitdiff
path: root/src/Array.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Array.hs')
-rw-r--r--src/Array.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Array.hs b/src/Array.hs
index 82c3f31..059600f 100644
--- a/src/Array.hs
+++ b/src/Array.hs
@@ -63,6 +63,13 @@ emptyShape (SS m) = emptyShape m `ShCons` 0
enumShape :: Shape n -> [Index n]
enumShape sh = map (fromLinearIndex sh) [0 .. shapeSize sh - 1]
+shapeToList :: Shape n -> [Int]
+shapeToList = go []
+ where
+ go :: [Int] -> Shape n -> [Int]
+ go suff ShNil = suff
+ go suff (sh `ShCons` n) = go (n:suff) sh
+
-- | TODO: this Vector is a boxed vector, which is horrendously inefficient.
data Array (n :: Nat) t = Array (Shape n) (Vector t)