summaryrefslogtreecommitdiff
path: root/src/Array.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-03-02 00:21:36 +0100
committerTom Smeding <tom@tomsmeding.com>2025-03-02 00:21:36 +0100
commit0fffb5731271a551afcf08878cb021ead8dd1dae (patch)
treefd4fff6010db0fb63515930708b3d8bfd234c367 /src/Array.hs
parent0ebdcff2aa06ee95f95597f2984e2cd335899d37 (diff)
compile: WIP reference-counted arrays
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)