From d0772f3ee0d647de38cf0fdb13d2372837a9fefe Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 13 May 2024 19:29:22 +0200 Subject: Rename StaticShape{R,S} to Sh{R,S}, because they encode runtime info ShS is a borderline case, though --- src/Data/Array/Nested/Internal.hs | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/Data/Array/Nested') diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index 594abd4..3f885e4 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -911,37 +911,37 @@ 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) +type role ShR nominal representational +type ShR :: INat -> Type -> Type +newtype ShR n i = ShR (ListR n i) deriving (Show, Eq, Ord) -deriving newtype instance Functor (StaticShapeR n) +deriving newtype instance Functor (ShR n) -instance Foldable (StaticShapeR n) where - foldr f z (StaticShapeR l) = foldr f z l +instance Foldable (ShR n) where + foldr f z (ShR l) = foldr f z l -pattern ZSR :: forall n i. () => n ~ Z => StaticShapeR n i -pattern ZSR = StaticShapeR ZR +pattern ZSR :: forall n i. () => n ~ Z => ShR n i +pattern ZSR = ShR ZR pattern (:$:) :: forall {n1} {i}. forall n. ((S n) ~ n1) - => i -> StaticShapeR n i -> StaticShapeR n1 i -pattern i :$: sh <- (unconsStaticShapeR -> Just (UnconsStaticShapeRRes sh i)) - where i :$: (StaticShapeR sh) = StaticShapeR (i ::: sh) + => i -> ShR n i -> ShR n1 i +pattern i :$: sh <- (unconsShR -> Just (UnconsShRRes sh i)) + where i :$: (ShR sh) = ShR (i ::: sh) {-# COMPLETE ZSR, (:$:) #-} infixr 3 :$: -data UnconsStaticShapeRRes i n1 = - forall n. ((S n) ~ n1) => UnconsStaticShapeRRes (StaticShapeR n i) i -unconsStaticShapeR :: StaticShapeR n1 i -> Maybe (UnconsStaticShapeRRes i n1) -unconsStaticShapeR (StaticShapeR sh) = case sh of - i ::: sh' -> Just (UnconsStaticShapeRRes (StaticShapeR sh') i) +data UnconsShRRes i n1 = + forall n. ((S n) ~ n1) => UnconsShRRes (ShR n i) i +unconsShR :: ShR n1 i -> Maybe (UnconsShRRes i n1) +unconsShR (ShR sh) = case sh of + i ::: sh' -> Just (UnconsShRRes (ShR sh') i) ZR -> Nothing -knownStaticShapeR :: StaticShapeR n i -> Dict KnownINat n -knownStaticShapeR (StaticShapeR sh) = knownListR sh +knownShR :: ShR n i -> Dict KnownINat n +knownShR (ShR sh) = knownListR sh zeroIxR :: SINat n -> IIxR n zeroIxR SZ = ZIR @@ -1131,33 +1131,33 @@ unconsIxS (IxS shl) = case shl of type IIxS sh = IxS sh Int -type role StaticShapeS nominal representational -type StaticShapeS :: [Nat] -> Type -> Type -newtype StaticShapeS sh i = StaticShapeS (ListS sh i) +type role ShS nominal representational +type ShS :: [Nat] -> Type -> Type +newtype ShS sh i = ShS (ListS sh i) deriving (Show, Eq, Ord) -deriving newtype instance Functor (StaticShapeS sh) +deriving newtype instance Functor (ShS sh) -instance Foldable (StaticShapeS sh) where - foldr f z (StaticShapeS l) = foldr f z l +instance Foldable (ShS sh) where + foldr f z (ShS l) = foldr f z l -pattern ZSS :: forall sh i. () => sh ~ '[] => StaticShapeS sh i -pattern ZSS = StaticShapeS ZS +pattern ZSS :: forall sh i. () => sh ~ '[] => ShS sh i +pattern ZSS = ShS ZS pattern (:$$) :: forall {sh1} {i}. forall n sh. (n : sh ~ sh1) - => i -> StaticShapeS sh i -> StaticShapeS sh1 i -pattern i :$$ shl <- (unconsStaticShapeS -> Just (UnconsStaticShapeSRes shl i)) - where i :$$ (StaticShapeS shl) = StaticShapeS (i ::$ shl) + => i -> ShS sh i -> ShS sh1 i +pattern i :$$ shl <- (unconsShS -> Just (UnconsShSRes shl i)) + where i :$$ (ShS shl) = ShS (i ::$ shl) {-# COMPLETE ZSS, (:$$) #-} infixr 3 :$$ -data UnconsStaticShapeSRes i sh1 = - forall n sh. (n : sh ~ sh1) => UnconsStaticShapeSRes (StaticShapeS sh i) i -unconsStaticShapeS :: StaticShapeS sh1 i -> Maybe (UnconsStaticShapeSRes i sh1) -unconsStaticShapeS (StaticShapeS shl) = case shl of - i ::$ shl' -> Just (UnconsStaticShapeSRes (StaticShapeS shl') i) +data UnconsShSRes i sh1 = + forall n sh. (n : sh ~ sh1) => UnconsShSRes (ShS sh i) i +unconsShS :: ShS sh1 i -> Maybe (UnconsShSRes i sh1) +unconsShS (ShS shl) = case shl of + i ::$ shl' -> Just (UnconsShSRes (ShS shl') i) ZS -> Nothing zeroIxS :: SShape sh -> IIxS sh -- cgit v1.2.3-70-g09d2