@@ -7,6 +7,7 @@
7{-# OPTIONS_HADDOCK not-home #-}
7{-# OPTIONS_HADDOCK not-home #-}
8module Servant.API.Alternative ((:<|>)(..)) where
8module Servant.API.Alternative ((:<|>)(..)) where
10+import Data.Semigroup (Semigroup (..))
10import Data.Typeable (Typeable)
11import Data.Typeable (Typeable)
11import Prelude ()
12import Prelude ()
12import Prelude.Compat
13import Prelude.Compat
@@ -23,6 +24,9 @@ data a :<|> b = a :<|> b
23 deriving (Typeable, Eq, Show, Functor, Traversable, Foldable, Bounded)
24 deriving (Typeable, Eq, Show, Functor, Traversable, Foldable, Bounded)
24infixr 8 :<|>
25infixr 8 :<|>
27+instance (Semigroup a, Semigroup b) => Semigroup (a :<|> b) where
28+ (a :<|> b) <> (a' :<|> b') = (a <> a') :<|> (b <> b')
26instance (Monoid a, Monoid b) => Monoid (a :<|> b) where
30instance (Monoid a, Monoid b) => Monoid (a :<|> b) where
27 mempty = mempty :<|> mempty
31 mempty = mempty :<|> mempty
28 (a :<|> b) `mappend` (a' :<|> b') = (a `mappend` a') :<|> (b `mappend` b')
32 (a :<|> b) `mappend` (a' :<|> b') = (a `mappend` a') :<|> (b `mappend` b')