From 97ea9bbf91c2e42718b734b4c025eb101ea8218d Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 23 May 2024 23:14:04 +0200 Subject: Add utility function --- src/Data/Array/Mixed.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') 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 -- cgit v1.2.3-70-g09d2