From f56ba83f256808b92284f2d3c6440bda398ee304 Mon Sep 17 00:00:00 2001 From: Mikolaj Konarski Date: Thu, 9 Apr 2026 15:40:41 +0200 Subject: Define a pair of conversions ixxFromIxS'/ixrFromIxS' anologous to ixsFromIxX'/ixsFromIxR' --- src/Data/Array/Nested/Convert.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Data/Array/Nested/Convert.hs b/src/Data/Array/Nested/Convert.hs index 6ae897c..a6a09f6 100644 --- a/src/Data/Array/Nested/Convert.hs +++ b/src/Data/Array/Nested/Convert.hs @@ -15,13 +15,13 @@ module Data.Array.Nested.Convert ( -- * Shape\/index\/list casting functions -- ** To ranked - ixrFromIxS, ixrFromIxX, shrFromShS, shrFromShXAnyShape, shrFromShX, + ixrFromIxS, ixrFromIxS', ixrFromIxX, shrFromShS, shrFromShXAnyShape, shrFromShX, listrCast, ixrCast, shrCast, -- ** To shaped ixsFromIxR, ixsFromIxR', ixsFromIxX, ixsFromIxX', withShsFromShR, shsFromShX, withShsFromShX, shsFromSSX, ixsCast, -- ** To mixed - ixxFromIxR, ixxFromIxS, shxFromShR, shxFromShS, + ixxFromIxR, ixxFromIxS, ixxFromIxS', shxFromShR, shxFromShS, ixxCast, shxCast, shxCast', -- * Array conversions @@ -62,6 +62,11 @@ ixrFromIxS = coerce Prelude.. (unsafeCoerce :: IxX (MapJust sh) i -> IxX (Replicate (Rank sh) Nothing) i) Prelude.. coerce +ixrFromIxS' :: forall sh i. SNat (Rank sh) -> IxS sh i -> IxR (Rank sh) i +ixrFromIxS' _ = coerce + Prelude.. (unsafeCoerce :: IxX (MapJust sh) i -> IxX (Replicate (Rank sh) Nothing) i) + Prelude.. coerce + -- ixrFromIxX re-exported shrFromShS :: ShS sh -> IShR (Rank sh) @@ -138,6 +143,9 @@ shsFromSSX = shsFromShX Prelude.. shxFromSSX -- ixxFromIxR re-exported -- ixxFromIxS re-exported +ixxFromIxS' :: StaticShX sh' -> IxS sh i -> IxX sh' i +ixxFromIxS' sh' = ixxCast sh' Prelude.. ixxFromIxS + shxFromShR :: ShR n i -> ShX (Replicate n Nothing) i shxFromShR = coerce -- cgit v1.3