aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Shaped/Shape.hs
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2025-12-16 20:43:38 +0100
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2026-02-18 14:23:02 +0100
commitb146be9b503c034438fe63423f5b2d1912686a34 (patch)
treef49b0598fb57666d8683e1f1d48f29cdcfdbad1f /src/Data/Array/Nested/Shaped/Shape.hs
parentbf9b6b8f147c1cb26bba4459d760723648f72b9d (diff)
De-triplicate ix?ToLinear
Diffstat (limited to 'src/Data/Array/Nested/Shaped/Shape.hs')
-rw-r--r--src/Data/Array/Nested/Shaped/Shape.hs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs
index 39be729..634c854 100644
--- a/src/Data/Array/Nested/Shaped/Shape.hs
+++ b/src/Data/Array/Nested/Shaped/Shape.hs
@@ -311,11 +311,10 @@ ixsPermutePrefix = coerce (listsPermutePrefix @(Const i))
-- index into the buffer.
{-# INLINEABLE ixsToLinear #-}
ixsToLinear :: Num i => ShS sh -> IxS sh i -> i
-ixsToLinear = \sh i -> go sh i 0
- where
- go :: Num i => ShS sh -> IxS sh i -> i -> i
- go ZSS ZIS a = a
- go (n :$$ sh) (i :.$ ix) a = go sh ix (fromIntegral (fromSNat' n) * a + i)
+ixsToLinear (ShS sh) ix = ixxToLinear sh (ixxFromIxS ix)
+
+ixxFromIxS :: IxS sh i -> IxX (MapJust sh) i
+ixxFromIxS = unsafeCoerce
{-# INLINEABLE ixsFromLinear #-}
ixsFromLinear :: Num i => ShS sh -> Int -> IxS sh i