@@ -7,6 +7,7 @@
77{-# OPTIONS_HADDOCK not-home #-}
88module Servant.API.Alternative ((:<|>)(..)) where
99
10+import Data.Semigroup (Semigroup (..))
1011import Data.Typeable (Typeable)
1112import Prelude ()
1213import Prelude.Compat
@@ -23,6 +24,9 @@ data a :<|> b = a :<|> b
2324 deriving (Typeable, Eq, Show, Functor, Traversable, Foldable, Bounded)
2425infixr 8 :<|>
2526
27+instance (Semigroup a, Semigroup b) => Semigroup (a :<|> b) where
28+ (a :<|> b) <> (a' :<|> b') = (a <> a') :<|> (b <> b')
29+
2630instance (Monoid a, Monoid b) => Monoid (a :<|> b) where
2731 mempty = mempty :<|> mempty
2832 (a :<|> b) `mappend` (a' :<|> b') = (a `mappend` a') :<|> (b `mappend` b')