    {-# LANGUAGE CPP                #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveFoldable     #-}
    {-# LANGUAGE DeriveFunctor      #-}
    {-# LANGUAGE DeriveTraversable  #-}
    {-# LANGUAGE TypeOperators      #-}
    {-# OPTIONS_HADDOCK not-home    #-}
    module Servant.API.Alternative ((:<|>)(..)) where

    import           Control.Applicative (liftA2)
    import           Data.Biapplicative
                     (Biapplicative (..))
    import           Data.Bifoldable
                     (Bifoldable (..))
    import           Data.Bifunctor
                     (Bifunctor (..))
    import           Data.Bitraversable
                     (Bitraversable (..))
    import           Data.Semigroup
                     (Semigroup (..))
    import           Data.Typeable
                     (Typeable)
    import           Prelude ()
    import           Prelude.Compat

    -- | Union of two APIs, first takes precedence in case of overlap.
    --
    -- Example:
    --
    -- >>> :{
    --type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
    --        :<|> "books" :> ReqBody '[JSON] Book :> Post '[JSON] () -- POST /books
    -- :}
    data a :<|> b = a :<|> b
        deriving (Typeable, (a :<|> b) -> (a :<|> b) -> Bool
    ((a :<|> b) -> (a :<|> b) -> Bool)
    -> ((a :<|> b) -> (a :<|> b) -> Bool) -> Eq (a :<|> b)
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    forall a b. (Eq a, Eq b) => (a :<|> b) -> (a :<|> b) -> Bool
    /= :: (a :<|> b) -> (a :<|> b) -> Bool
    $c/= :: forall a b. (Eq a, Eq b) => (a :<|> b) -> (a :<|> b) -> Bool
    == :: (a :<|> b) -> (a :<|> b) -> Bool
    $c== :: forall a b. (Eq a, Eq b) => (a :<|> b) -> (a :<|> b) -> Bool
    Eq, Int -> (a :<|> b) -> ShowS
    [a :<|> b] -> ShowS
    (a :<|> b) -> String
    (Int -> (a :<|> b) -> ShowS)
    -> ((a :<|> b) -> String)
    -> ([a :<|> b] -> ShowS)
    -> Show (a :<|> b)
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    forall a b. (Show a, Show b) => Int -> (a :<|> b) -> ShowS
    forall a b. (Show a, Show b) => [a :<|> b] -> ShowS
    forall a b. (Show a, Show b) => (a :<|> b) -> String
    showList :: [a :<|> b] -> ShowS
    $cshowList :: forall a b. (Show a, Show b) => [a :<|> b] -> ShowS
    show :: (a :<|> b) -> String
    $cshow :: forall a b. (Show a, Show b) => (a :<|> b) -> String
    showsPrec :: Int -> (a :<|> b) -> ShowS
    $cshowsPrec :: forall a b. (Show a, Show b) => Int -> (a :<|> b) -> ShowS
    Show, a -> (a :<|> b) -> a :<|> a
    (a -> b) -> (a :<|> a) -> a :<|> b
    (forall a b. (a -> b) -> (a :<|> a) -> a :<|> b)
    -> (forall a b. a -> (a :<|> b) -> a :<|> a) -> Functor ((:<|>) a)
    forall a b. a -> (a :<|> b) -> a :<|> a
    forall a b. (a -> b) -> (a :<|> a) -> a :<|> b
    forall a a b. a -> (a :<|> b) -> a :<|> a
    forall a a b. (a -> b) -> (a :<|> a) -> a :<|> b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    <$ :: a -> (a :<|> b) -> a :<|> a
    $c<$ :: forall a a b. a -> (a :<|> b) -> a :<|> a
    fmap :: (a -> b) -> (a :<|> a) -> a :<|> b
    $cfmap :: forall a a b. (a -> b) -> (a :<|> a) -> a :<|> b
    Functor, Functor ((:<|>) a)
    Foldable ((:<|>) a)
    (Functor ((:<|>) a), Foldable ((:<|>) a)) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> (a :<|> a) -> f (a :<|> b))
    -> (forall (f :: * -> *) a.
        Applicative f =>
        (a :<|> f a) -> f (a :<|> a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> (a :<|> a) -> m (a :<|> b))
    -> (forall (m :: * -> *) a.
        Monad m =>
        (a :<|> m a) -> m (a :<|> a))
    -> Traversable ((:<|>) a)
    (a -> f b) -> (a :<|> a) -> f (a :<|> b)
    forall a. Functor ((:<|>) a)
    forall a. Foldable ((:<|>) a)
    forall a (m :: * -> *) a. Monad m => (a :<|> m a) -> m (a :<|> a)
    forall a (f :: * -> *) a.
    Applicative f =>
    (a :<|> f a) -> f (a :<|> a)
    forall a (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> (a :<|> a) -> m (a :<|> b)
    forall a (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> (a :<|> a) -> f (a :<|> b)
    forall (t :: * -> *).
    (Functor t, Foldable t) =>
    (forall (f :: * -> *) a b.
     Applicative f =>
     (a -> f b) -> t a -> f (t b))
    -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
    -> (forall (m :: * -> *) a b.
        Monad m =>
        (a -> m b) -> t a -> m (t b))
    -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
    -> Traversable t
    forall (m :: * -> *) a. Monad m => (a :<|> m a) -> m (a :<|> a)
    forall (f :: * -> *) a.
    Applicative f =>
    (a :<|> f a) -> f (a :<|> a)
    forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> (a :<|> a) -> m (a :<|> b)
    forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> (a :<|> a) -> f (a :<|> b)
    sequence :: (a :<|> m a) -> m (a :<|> a)
    $csequence :: forall a (m :: * -> *) a. Monad m => (a :<|> m a) -> m (a :<|> a)
    mapM :: (a -> m b) -> (a :<|> a) -> m (a :<|> b)
    $cmapM :: forall a (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> (a :<|> a) -> m (a :<|> b)
    sequenceA :: (a :<|> f a) -> f (a :<|> a)
    $csequenceA :: forall a (f :: * -> *) a.
    Applicative f =>
    (a :<|> f a) -> f (a :<|> a)
    traverse :: (a -> f b) -> (a :<|> a) -> f (a :<|> b)
    $ctraverse :: forall a (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> (a :<|> a) -> f (a :<|> b)
    $cp2Traversable :: forall a. Foldable ((:<|>) a)
    $cp1Traversable :: forall a. Functor ((:<|>) a)
    Traversable, (a :<|> a) -> Bool
    (a -> m) -> (a :<|> a) -> m
    (a -> b -> b) -> b -> (a :<|> a) -> b
    (forall m. Monoid m => (a :<|> m) -> m)
    -> (forall m a. Monoid m => (a -> m) -> (a :<|> a) -> m)
    -> (forall m a. Monoid m => (a -> m) -> (a :<|> a) -> m)
    -> (forall a b. (a -> b -> b) -> b -> (a :<|> a) -> b)
    -> (forall a b. (a -> b -> b) -> b -> (a :<|> a) -> b)
    -> (forall b a. (b -> a -> b) -> b -> (a :<|> a) -> b)
    -> (forall b a. (b -> a -> b) -> b -> (a :<|> a) -> b)
    -> (forall a. (a -> a -> a) -> (a :<|> a) -> a)
    -> (forall a. (a -> a -> a) -> (a :<|> a) -> a)
    -> (forall a. (a :<|> a) -> [a])
    -> (forall a. (a :<|> a) -> Bool)
    -> (forall a. (a :<|> a) -> Int)
    -> (forall a. Eq a => a -> (a :<|> a) -> Bool)
    -> (forall a. Ord a => (a :<|> a) -> a)
    -> (forall a. Ord a => (a :<|> a) -> a)
    -> (forall a. Num a => (a :<|> a) -> a)
    -> (forall a. Num a => (a :<|> a) -> a)
    -> Foldable ((:<|>) a)
    forall a. Eq a => a -> (a :<|> a) -> Bool
    forall a. Num a => (a :<|> a) -> a
    forall a. Ord a => (a :<|> a) -> a
    forall m. Monoid m => (a :<|> m) -> m
    forall a. (a :<|> a) -> Bool
    forall a. (a :<|> a) -> Int
    forall a. (a :<|> a) -> [a]
    forall a. (a -> a -> a) -> (a :<|> a) -> a
    forall a a. Eq a => a -> (a :<|> a) -> Bool
    forall a a. Num a => (a :<|> a) -> a
    forall a a. Ord a => (a :<|> a) -> a
    forall m a. Monoid m => (a -> m) -> (a :<|> a) -> m
    forall a m. Monoid m => (a :<|> m) -> m
    forall a a. (a :<|> a) -> Bool
    forall a a. (a :<|> a) -> Int
    forall a a. (a :<|> a) -> [a]
    forall b a. (b -> a -> b) -> b -> (a :<|> a) -> b
    forall a b. (a -> b -> b) -> b -> (a :<|> a) -> b
    forall a a. (a -> a -> a) -> (a :<|> a) -> a
    forall a m a. Monoid m => (a -> m) -> (a :<|> a) -> m
    forall a b a. (b -> a -> b) -> b -> (a :<|> a) -> b
    forall a a b. (a -> b -> b) -> b -> (a :<|> a) -> b
    forall (t :: * -> *).
    (forall m. Monoid m => t m -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall m a. Monoid m => (a -> m) -> t a -> m)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall a b. (a -> b -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall b a. (b -> a -> b) -> b -> t a -> b)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. (a -> a -> a) -> t a -> a)
    -> (forall a. t a -> [a])
    -> (forall a. t a -> Bool)
    -> (forall a. t a -> Int)
    -> (forall a. Eq a => a -> t a -> Bool)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Ord a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> (forall a. Num a => t a -> a)
    -> Foldable t
    product :: (a :<|> a) -> a
    $cproduct :: forall a a. Num a => (a :<|> a) -> a
    sum :: (a :<|> a) -> a
    $csum :: forall a a. Num a => (a :<|> a) -> a
    minimum :: (a :<|> a) -> a
    $cminimum :: forall a a. Ord a => (a :<|> a) -> a
    maximum :: (a :<|> a) -> a
    $cmaximum :: forall a a. Ord a => (a :<|> a) -> a
    elem :: a -> (a :<|> a) -> Bool
    $celem :: forall a a. Eq a => a -> (a :<|> a) -> Bool
    length :: (a :<|> a) -> Int
    $clength :: forall a a. (a :<|> a) -> Int
    null :: (a :<|> a) -> Bool
    $cnull :: forall a a. (a :<|> a) -> Bool
    toList :: (a :<|> a) -> [a]
    $ctoList :: forall a a. (a :<|> a) -> [a]
    foldl1 :: (a -> a -> a) -> (a :<|> a) -> a
    $cfoldl1 :: forall a a. (a -> a -> a) -> (a :<|> a) -> a
    foldr1 :: (a -> a -> a) -> (a :<|> a) -> a
    $cfoldr1 :: forall a a. (a -> a -> a) -> (a :<|> a) -> a
    foldl' :: (b -> a -> b) -> b -> (a :<|> a) -> b
    $cfoldl' :: forall a b a. (b -> a -> b) -> b -> (a :<|> a) -> b
    foldl :: (b -> a -> b) -> b -> (a :<|> a) -> b
    $cfoldl :: forall a b a. (b -> a -> b) -> b -> (a :<|> a) -> b
    foldr' :: (a -> b -> b) -> b -> (a :<|> a) -> b
    $cfoldr' :: forall a a b. (a -> b -> b) -> b -> (a :<|> a) -> b
    foldr :: (a -> b -> b) -> b -> (a :<|> a) -> b
    $cfoldr :: forall a a b. (a -> b -> b) -> b -> (a :<|> a) -> b
    foldMap' :: (a -> m) -> (a :<|> a) -> m
    $cfoldMap' :: forall a m a. Monoid m => (a -> m) -> (a :<|> a) -> m
    foldMap :: (a -> m) -> (a :<|> a) -> m
    $cfoldMap :: forall a m a. Monoid m => (a -> m) -> (a :<|> a) -> m
    fold :: (a :<|> m) -> m
    $cfold :: forall a m. Monoid m => (a :<|> m) -> m
    Foldable, a :<|> b
    (a :<|> b) -> (a :<|> b) -> Bounded (a :<|> b)
    forall a. a -> a -> Bounded a
    forall a b. (Bounded a, Bounded b) => a :<|> b
    maxBound :: a :<|> b
    $cmaxBound :: forall a b. (Bounded a, Bounded b) => a :<|> b
    minBound :: a :<|> b
    $cminBound :: forall a b. (Bounded a, Bounded b) => a :<|> b
    Bounded)
    infixr 3 :<|>

    instance (Semigroup a, Semigroup b) => Semigroup (a :<|> b) where
        (a :: a
    a :<|> b :: b
    b) <> :: (a :<|> b) -> (a :<|> b) -> a :<|> b
    <> (a' :: a
    a' :<|> b' :: b
    b') = (a
    a a -> a -> a
    forall a. Semigroup a => a -> a -> a
    <> a
    a') a -> b -> a :<|> b
    forall a b. a -> b -> a :<|> b
    :<|> (b
    b b -> b -> b
    forall a. Semigroup a => a -> a -> a
    <> b
    b')

    instance (Monoid a, Monoid b) => Monoid (a :<|> b) where
        mempty :: a :<|> b
    mempty = a
    forall a. Monoid a => a
    mempty a -> b -> a :<|> b
    forall a b. a -> b -> a :<|> b
    :<|> b
    forall a. Monoid a => a
    mempty
        (a :: a
    a :<|> b :: b
    b) mappend :: (a :<|> b) -> (a :<|> b) -> a :<|> b
    `mappend` (a' :: a
    a' :<|> b' :: b
    b') = (a
    a a -> a -> a
    forall a. Monoid a => a -> a -> a
    `mappend` a
    a') a -> b -> a :<|> b
    forall a b. a -> b -> a :<|> b
    :<|> (b
    b b -> b -> b
    forall a. Monoid a => a -> a -> a
    `mappend` b
    b')

    instance Bifoldable (:<|>) where
        bifoldMap :: (a -> m) -> (b -> m) -> (a :<|> b) -> m
    bifoldMap f :: a -> m
    f g :: b -> m
    g ~(a :: a
    a :<|> b :: b
    b) = a -> m
    f a
    a m -> m -> m
    forall a. Monoid a => a -> a -> a
    `mappend` b -> m
    g b
    b

    instance Bifunctor (:<|>) where
        bimap :: (a -> b) -> (c -> d) -> (a :<|> c) -> b :<|> d
    bimap f :: a -> b
    f g :: c -> d
    g ~(a :: a
    a :<|> b :: c
    b) = a -> b
    f a
    a b -> d -> b :<|> d
    forall a b. a -> b -> a :<|> b
    :<|> c -> d
    g c
    b

    instance Biapplicative (:<|>) where
        bipure :: a -> b -> a :<|> b
    bipure = a -> b -> a :<|> b
    forall a b. a -> b -> a :<|> b
    (:<|>)
        (f :: a -> b
    f :<|> g :: c -> d
    g) <<*>> :: ((a -> b) :<|> (c -> d)) -> (a :<|> c) -> b :<|> d
    <<*>> (a :: a
    a :<|> b :: c
    b) = a -> b
    f a
    a b -> d -> b :<|> d
    forall a b. a -> b -> a :<|> b
    :<|> c -> d
    g c
    b

    instance Bitraversable (:<|>) where
        bitraverse :: (a -> f c) -> (b -> f d) -> (a :<|> b) -> f (c :<|> d)
    bitraverse f :: a -> f c
    f g :: b -> f d
    g ~(a :: a
    a :<|> b :: b
    b) = (c -> d -> c :<|> d) -> f c -> f d -> f (c :<|> d)
    forall (f :: * -> *) a b c.
    Applicative f =>
    (a -> b -> c) -> f a -> f b -> f c
    liftA2 c -> d -> c :<|> d
    forall a b. a -> b -> a :<|> b
    (:<|>) (a -> f c
    f a
    a) (b -> f d
    g b
    b)

    -- $setup
    -- >>> import Servant.API
    -- >>> import Data.Aeson
    -- >>> import Data.Text
    -- >>> data Book
    -- >>> instance ToJSON Book where { toJSON = undefined }