diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-12-20 18:23:34 +0100 |
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-12-20 19:59:39 +0100 |
| commit | bc8e904b3cc7b98a4809357321ce3d1196df3701 (patch) | |
| tree | fd0e0fa01b75d126da213cd90afb70bd00b5f971 /src/Data/Array/Nested/Convert.hs | |
| parent | d076a85139c89f20898f957220825c0449eafb4f (diff) | |
Remove ixsFromIxR' and simplify ixsFromIxR
Diffstat (limited to 'src/Data/Array/Nested/Convert.hs')
| -rw-r--r-- | src/Data/Array/Nested/Convert.hs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/Data/Array/Nested/Convert.hs b/src/Data/Array/Nested/Convert.hs index 86534f1..408bf8a 100644 --- a/src/Data/Array/Nested/Convert.hs +++ b/src/Data/Array/Nested/Convert.hs @@ -18,7 +18,7 @@ module Data.Array.Nested.Convert ( ixrFromIxS, ixrFromIxX, shrFromShS, shrFromShXAnyShape, shrFromShX, listrCast, ixrCast, shrCast, -- ** To shaped - ixsFromIxR, ixsFromIxR', ixsFromIxX, ixsFromIxX', withShsFromShR, shsFromShX, withShsFromShX, shsFromSSX, + ixsFromIxR, ixsFromIxX, ixsFromIxX', withShsFromShR, shsFromShX, withShsFromShX, shsFromSSX, ixsCast, -- ** To mixed ixxFromIxR, ixxFromIxS, shxFromShR, shxFromShS, @@ -59,7 +59,8 @@ import Data.Array.Nested.Types -- TODO: change all those unsafeCoerces into coerces by defining shaped -- and ranekd index types as newtypes of the mixed index type --- and similarly for the sized lists +-- and similarly for the sized lists or, preferably, by defining +-- all as newtypes over [], exploiting fusion and getting free toList. ixrFromIxS :: IxS sh i -> IxR (Rank sh) i ixrFromIxS = unsafeCoerce @@ -82,25 +83,13 @@ shrFromShX = coerce -- * To shaped --- TODO: remove the ShS now that no KnownNats is inside IxS. -ixsFromIxR :: ShS sh -> IxR (Rank sh) i -> IxS sh i -ixsFromIxR _ = unsafeCoerce - --- TODO: if possible, remove the ShS now that no KnownNats is inside IxS. --- | Performs a runtime check that @n@ matches @Rank sh@. Equivalent to the --- following, but more efficient: --- --- > ixsFromIxR' sh idx = ixsFromIxR sh (ixrCast (shsRank sh) idx) -ixsFromIxR' :: ShS sh -> IxR n i -> IxS sh i -ixsFromIxR' ZSS ZIR = ZIS -ixsFromIxR' (_ :$$ sh) (n :.: idx) = n :.$ ixsFromIxR' sh idx -ixsFromIxR' _ _ = error "ixsFromIxR': index rank does not match shape rank" +ixsFromIxR :: IxR (Rank sh) i -> IxS sh i +ixsFromIxR = unsafeCoerce -- TODO: switch to coerce once newtypes overhauled -- ixsFromIxX re-exported --- TODO: if possible, remove the ShS now that no KnownNats is inside IxS. -- | Performs a runtime check that @Rank sh'@ match @Rank sh@. Equivalent to --- the following, but more efficient: +-- the following, but less verbose: -- -- > ixsFromIxX' sh idx = ixsFromIxX sh (ixxCast (shxFromShS sh) idx) ixsFromIxX' :: ShS sh -> IxX sh' i -> IxS sh i |
