diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-11-18 12:57:17 +0100 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-11-18 12:57:17 +0100 |
| commit | a158f928c6d617fa950f74c517e94c5062422efd (patch) | |
| tree | a82cc806c9b2cfd45183e6b65f98c377575af41a /src/Data/Array/Nested/Mixed | |
| parent | e53b10d35bdb414520ac1d5b00307c4c62a9e1db (diff) | |
The explicit usage at Int in the non-primed versions of the functions
results in an auto-generated SPEC rule at Int, so even without any
SPECIALIZE pragmas, using sh?Enum' at Int should not (need to) result in
multiple specialisations.
Diffstat (limited to 'src/Data/Array/Nested/Mixed')
| -rw-r--r-- | src/Data/Array/Nested/Mixed/Shape.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape.hs b/src/Data/Array/Nested/Mixed/Shape.hs index 8777739..0464f1f 100644 --- a/src/Data/Array/Nested/Mixed/Shape.hs +++ b/src/Data/Array/Nested/Mixed/Shape.hs @@ -472,11 +472,15 @@ shxSplitApp _ ZKX idx = (ZSX, idx) shxSplitApp p (_ :!% ssh) (i :$% idx) = first (i :$%) (shxSplitApp p ssh idx) shxEnum :: IShX sh -> [IIxX sh] -shxEnum = \sh -> go sh id [] +shxEnum = shxEnum' + +{-# INLINABLE shxEnum' #-} -- ensure this can be specialised at use site +shxEnum' :: Num i => IShX sh -> [IxX sh i] +shxEnum' = \sh -> go sh id [] where - go :: IShX sh -> (IIxX sh -> a) -> [a] -> [a] + go :: Num i => IShX sh -> (IxX sh i -> a) -> [a] -> [a] go ZSX f = (f ZIX :) - go (n :$% sh) f = foldr (.) id [go sh (f . (i :.%)) | i <- [0 .. fromSMayNat' n - 1]] + go (n :$% sh) f = foldr (.) id [go sh (f . (fromIntegral i :.%)) | i <- [0 .. fromSMayNat' n - 1]] shxCast :: StaticShX sh' -> IShX sh -> Maybe (IShX sh') shxCast ZKX ZSX = Just ZSX |
