aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Mixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Nested/Mixed')
-rw-r--r--src/Data/Array/Nested/Mixed/Shape.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape.hs b/src/Data/Array/Nested/Mixed/Shape.hs
index ed03310..f755703 100644
--- a/src/Data/Array/Nested/Mixed/Shape.hs
+++ b/src/Data/Array/Nested/Mixed/Shape.hs
@@ -231,11 +231,13 @@ ixxLength (IxX l) = listxLength l
ixxRank :: IxX sh i -> SNat (Rank sh)
ixxRank (IxX l) = listxRank l
-ixxZero :: StaticShX sh -> IIxX sh
+{-# INLINEABLE ixxZero #-}
+ixxZero :: Num i => StaticShX sh -> IxX sh i
ixxZero ZKX = ZIX
ixxZero (_ :!% ssh) = 0 :.% ixxZero ssh
-ixxZero' :: IShX sh -> IIxX sh
+{-# INLINEABLE ixxZero' #-}
+ixxZero' :: Num i => IShX sh -> IxX sh i
ixxZero' ZSX = ZIX
ixxZero' (_ :$% sh) = 0 :.% ixxZero' sh
@@ -301,15 +303,16 @@ ixxFromLinear = \sh -> -- give this function arity 1 so that suffixes is shared
outrange sh i = error $ "ixxFromLinear: out of range (" ++ show i ++
" in array of shape " ++ show sh ++ ")"
-ixxToLinear :: IShX sh -> IIxX sh -> Int
+{-# INLINEABLE ixxToLinear #-}
+ixxToLinear :: Integral i => IShX sh -> IxX sh i -> Int
ixxToLinear = \sh i -> fst (go sh i)
where
-- returns (index in subarray, size of subarray)
- go :: IShX sh -> IIxX sh -> (Int, Int)
+ go :: Integral i => IShX sh -> IxX sh i -> (Int, Int)
go ZSX ZIX = (0, 1)
go (n :$% sh) (i :.% ix) =
let (lidx, sz) = go sh ix
- in (sz * i + lidx, fromSMayNat' n * sz)
+ in (sz * fromIntegral i + lidx, fromSMayNat' n * sz)
-- * Mixed shapes