diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-03-16 14:36:36 +0100 |
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-03-16 14:36:36 +0100 |
| commit | fc2a1370d67f12b50e3e5750d17aefd33bc3d8a3 (patch) | |
| tree | 5a3bb2d84adcd6e9bca74034d884837996467ea1 /src/Data/Array/Nested/Shaped/Shape.hs | |
| parent | 8409fa81c7b31bf8ace0b1f219ba6a1a7cbdf2de (diff) | |
Fill and clean up *TakeIx and *DropIx functionsmvecsReplicate
Diffstat (limited to 'src/Data/Array/Nested/Shaped/Shape.hs')
| -rw-r--r-- | src/Data/Array/Nested/Shaped/Shape.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs index f98c860..ef91c7b 100644 --- a/src/Data/Array/Nested/Shaped/Shape.hs +++ b/src/Data/Array/Nested/Shaped/Shape.hs @@ -30,6 +30,7 @@ import Data.Array.Shape qualified as O import Data.Coerce (coerce) import Data.Foldable qualified as Foldable import Data.Kind (Constraint, Type) +import Data.Proxy import Data.Type.Equality import GHC.Exts (build, withDict) import GHC.IsList (IsList) @@ -394,6 +395,16 @@ shsHead (ShS shx) = case shxHead shx of shsTail :: forall n sh. ShS (n : sh) -> ShS sh shsTail = coerce (shxTail @_ @_ @Int) +{-# INLINEABLE shsTakeIx #-} +shsTakeIx :: forall sh sh' j. Proxy sh' -> IxS sh j -> ShS (sh ++ sh') -> ShS sh +shsTakeIx _ ZIS _ = ZSS +shsTakeIx p (_ :.$ idx) sh = case sh of n :$$ sh' -> n :$$ shsTakeIx p idx sh' + +{-# INLINEABLE shsDropIx #-} +shsDropIx :: forall sh sh' j. IxS sh j -> ShS (sh ++ sh') -> ShS sh' +shsDropIx ZIS long = long +shsDropIx (_ :.$ short) long = case long of _ :$$ long' -> shsDropIx short long' + shsInit :: forall n sh. ShS (n : sh) -> ShS (Init (n : sh)) shsInit = gcastWith (unsafeCoerceRefl |
