diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-12-02 13:16:33 +0100 |
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2025-12-02 13:16:33 +0100 |
| commit | 9f47aa6a2bcd772388a5d5150ca7254e4eb95bc2 (patch) | |
| tree | 4c3a1b8a7b1a734e83f161f2b1be58ce4470cfa3 /src/Data/Array/Nested/Mixed/Shape.hs | |
| parent | ba5a31c976f80421464af1af8d6ab1e2a154cd83 (diff) | |
Generalize mgeneratePrim to potentially avoid @fmap fromIntegral@
Diffstat (limited to 'src/Data/Array/Nested/Mixed/Shape.hs')
| -rw-r--r-- | src/Data/Array/Nested/Mixed/Shape.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape.hs b/src/Data/Array/Nested/Mixed/Shape.hs index 066ae8e..ed03310 100644 --- a/src/Data/Array/Nested/Mixed/Shape.hs +++ b/src/Data/Array/Nested/Mixed/Shape.hs @@ -275,7 +275,7 @@ ixxZipWith _ ZIX ZIX = ZIX ixxZipWith f (i :.% is) (j :.% js) = f i j :.% ixxZipWith f is js {-# INLINEABLE ixxFromLinear #-} -ixxFromLinear :: IShX sh -> Int -> IIxX sh +ixxFromLinear :: Num i => IShX sh -> Int -> IxX sh i ixxFromLinear = \sh -> -- give this function arity 1 so that suffixes is shared when it's called many times let suffixes = drop 1 (scanr (*) 1 (shxToList sh)) in \i -> @@ -286,14 +286,14 @@ ixxFromLinear = \sh -> -- give this function arity 1 so that suffixes is shared (n :$% sh', suff : suffs) -> let (q, r) = i `quotRem` suff in if q >= fromSMayNat' n then outrange sh i else - q :.% fromLin sh' suffs r + fromIntegral q :.% fromLin sh' suffs r _ -> error "impossible" where - fromLin :: IShX sh -> [Int] -> Int -> IxX sh Int + fromLin :: Num i => IShX sh -> [Int] -> Int -> IxX sh i fromLin ZSX _ !_ = ZIX fromLin (_ :$% sh') (suff : suffs) i = let (q, r) = i `quotRem` suff -- suff == shrSize sh' - in q :.% fromLin sh' suffs r + in fromIntegral q :.% fromLin sh' suffs r fromLin _ _ _ = error "impossible" {-# NOINLINE outrange #-} |
