From aeb62e1d59b4cdc426f6ca0ef8df6a0737bb0f86 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Tue, 18 Nov 2025 11:39:39 +0100 Subject: Add shsEnum and shrEnum --- src/Data/Array/Nested/Ranked/Shape.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Data/Array/Nested/Ranked/Shape.hs') diff --git a/src/Data/Array/Nested/Ranked/Shape.hs b/src/Data/Array/Nested/Ranked/Shape.hs index 488b4d8..a1fa247 100644 --- a/src/Data/Array/Nested/Ranked/Shape.hs +++ b/src/Data/Array/Nested/Ranked/Shape.hs @@ -330,6 +330,13 @@ shrZipWith f (ShR l1) (ShR l2) = ShR $ listrZipWith f l1 l2 shrPermutePrefix :: forall n i. [Int] -> ShR n i -> ShR n i shrPermutePrefix = coerce (listrPermutePrefix @i) +shrEnum :: IShR sh -> [IIxR sh] +shrEnum = \sh -> go sh id [] + where + go :: IShR sh -> (IIxR sh -> a) -> [a] -> [a] + go ZSR f = (f ZIR :) + go (n :$: sh) f = foldr (.) id [go sh (f . (i :.:)) | i <- [0 .. n - 1]] + -- | Untyped: length is checked at runtime. instance KnownNat n => IsList (ListR n i) where -- cgit v1.2.3-70-g09d2