aboutsummaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-23 23:14:04 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-23 23:14:04 +0200
commit97ea9bbf91c2e42718b734b4c025eb101ea8218d (patch)
tree27322b269683a82539765d051b43a798fe75cc79 /src/Data
parent2ef5f573f15ff2406b568b7bae79d0cf52eecc4b (diff)
Add utility function
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Array/Mixed.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index 7293914..748914c 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -433,6 +433,14 @@ type family Flatten' acc sh where
Flatten' acc (Nothing : sh) = Nothing
Flatten' acc (Just n : sh) = Flatten' (acc * n) sh
+flattenSSX :: StaticShX sh -> SMayNat () SNat (Flatten sh)
+flattenSSX = go (SNat @1)
+ where
+ go :: SNat acc -> StaticShX sh -> SMayNat () SNat (Flatten' acc sh)
+ go acc ZKX = SKnown acc
+ go _ (SUnknown () :!% _) = SUnknown ()
+ go acc (SKnown sn :!% sh) = go (mulSNat acc sn) sh
+
flattenSh :: IShX sh -> SMayNat Int SNat (Flatten sh)
flattenSh = go (SNat @1)
where