aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Shaped
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Nested/Shaped')
-rw-r--r--src/Data/Array/Nested/Shaped/Shape.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs
index 10e1a9d..6eaec10 100644
--- a/src/Data/Array/Nested/Shaped/Shape.hs
+++ b/src/Data/Array/Nested/Shaped/Shape.hs
@@ -389,6 +389,13 @@ shsFromListS (_ ::$ l) = SNat :$$ shsFromListS l
shsFromIxS :: IxS sh i -> ShS sh
shsFromIxS (IxS l) = shsFromListS l
+shsEnum :: ShS sh -> [IIxS sh]
+shsEnum = \sh -> go sh id []
+ where
+ go :: ShS sh -> (IIxS sh -> a) -> [a] -> [a]
+ go ZSS f = (f ZIS :)
+ go (n :$$ sh) f = foldr (.) id [go sh (f . (i :.$)) | i <- [0 .. fromSNat' n - 1]]
+
-- | Untyped: length is checked at runtime.
instance KnownShS sh => IsList (ListS sh (Const i)) where