From de187b9b7e9cbdb79429c505f1e0f9954593c76c Mon Sep 17 00:00:00 2001 From: Mikolaj Konarski Date: Tue, 16 Dec 2025 20:43:38 +0100 Subject: De-triplicate ix?ToLinear --- src/Data/Array/Nested/Shaped/Shape.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/Data/Array/Nested/Shaped') 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 -- cgit v1.2.3-70-g09d2