@@ -41,6 +41,7 @@ module Data.Generics.Product.Internal.List
4141 ) where
4242
4343import GHC.TypeLits
44+import Data.Semigroup
4445
4546import Data.Kind (Type)
4647import GHC.Generics
@@ -58,10 +59,16 @@ type family ((as :: [k]) ++ (bs :: [k])) :: [k] where
5859 '[] ++ bs = bs
5960 (a ': as) ++ bs = a ': as ++ bs
6061
62+instance Semigroup (List '[]) where
63+ _ <> _ = Nil
64+
6165instance Monoid (List '[]) where
6266 mempty = Nil
6367 mappend _ _ = Nil
6468
69+instance (Semigroup a, Semigroup (List as)) => Semigroup (List ('(k, a) ': as)) where
70+ (x :> xs) <> (y :> ys) = (x <> y) :> (xs <> ys)
71+
6572instance (Monoid a, Monoid (List as)) => Monoid (List ('(k, a) ': as)) where
6673 mempty = mempty :> mempty
6774 mappend (x :> xs) (y :> ys) = mappend x y :> mappend xs ys