From 4808710e311a69326c6fdef9fc1b9b2173fd009e Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 13 May 2024 19:52:46 +0200 Subject: Less manual Foldable instances --- src/Data/Array/Nested/Internal.hs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/Data/Array/Nested/Internal.hs') diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index 4577967..18f458e 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -896,10 +896,7 @@ type role IxR nominal representational type IxR :: INat -> Type -> Type newtype IxR n i = IxR (ListR n i) deriving (Show, Eq, Ord) - deriving newtype (Functor) - -instance Foldable (IxR n) where - foldr f z (IxR l) = foldr f z l + deriving newtype (Functor, Foldable) pattern ZIR :: forall n i. () => n ~ Z => IxR n i pattern ZIR = IxR ZR @@ -928,10 +925,7 @@ type role ShR nominal representational type ShR :: INat -> Type -> Type newtype ShR n i = ShR (ListR n i) deriving (Show, Eq, Ord) - deriving newtype (Functor) - -instance Foldable (ShR n) where - foldr f z (ShR l) = foldr f z l + deriving newtype (Functor, Foldable) pattern ZSR :: forall n i. () => n ~ Z => ShR n i pattern ZSR = ShR ZR @@ -1115,10 +1109,7 @@ type role IxS nominal representational type IxS :: [Nat] -> Type -> Type newtype IxS sh i = IxS (ListS sh i) deriving (Show, Eq, Ord) - deriving newtype (Functor) - -instance Foldable (IxS sh) where - foldr f z (IxS l) = foldr f z l + deriving newtype (Functor, Foldable) pattern ZIS :: forall sh i. () => sh ~ '[] => IxS sh i pattern ZIS = IxS ZS @@ -1144,10 +1135,7 @@ type role ShS nominal representational type ShS :: [Nat] -> Type -> Type newtype ShS sh i = ShS (ListS sh i) deriving (Show, Eq, Ord) - deriving newtype (Functor) - -instance Foldable (ShS sh) where - foldr f z (ShS l) = foldr f z l + deriving newtype (Functor, Foldable) pattern ZSS :: forall sh i. () => sh ~ '[] => ShS sh i pattern ZSS = ShS ZS -- cgit v1.2.3-70-g09d2