diff options
Diffstat (limited to 'src/Data/Array/Nested/Internal.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index fb2ae48..594abd4 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -872,6 +872,10 @@ listRToList :: ListR n i -> [i] listRToList ZR = [] listRToList (i ::: is) = i : listRToList is +knownListR :: ListR n i -> Dict KnownINat n +knownListR ZR = Dict +knownListR (_ ::: l) | Dict <- knownListR l = Dict + -- | An index into a rank-typed array. type role IxR nominal representational type IxR :: INat -> Type -> Type @@ -904,6 +908,9 @@ unconsIxR (IxR sh) = case sh of type IIxR n = IxR n Int +knownIxR :: IxR n i -> Dict KnownINat n +knownIxR (IxR sh) = knownListR sh + type role StaticShapeR nominal representational type StaticShapeR :: INat -> Type -> Type newtype StaticShapeR n i = StaticShapeR (ListR n i) @@ -933,6 +940,9 @@ unconsStaticShapeR (StaticShapeR sh) = case sh of i ::: sh' -> Just (UnconsStaticShapeRRes (StaticShapeR sh') i) ZR -> Nothing +knownStaticShapeR :: StaticShapeR n i -> Dict KnownINat n +knownStaticShapeR (StaticShapeR sh) = knownListR sh + zeroIxR :: SINat n -> IIxR n zeroIxR SZ = ZIR zeroIxR (SS n) = 0 :.: zeroIxR n @@ -946,10 +956,6 @@ ixCvtRX :: IIxR n -> IIxX (Replicate n Nothing) ixCvtRX ZIR = ZIX ixCvtRX (n :.: idx) = n :.? ixCvtRX idx -knownIxR :: IIxR n -> Dict KnownINat n -knownIxR ZIR = Dict -knownIxR (_ :.: idx) | Dict <- knownIxR idx = Dict - shapeSizeR :: IIxR n -> Int shapeSizeR ZIR = 1 shapeSizeR (n :.: sh) = n * shapeSizeR sh |