{-# 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.Typeable
(Typeable)
import Prelude ()
import Prelude.Compat
data a :<|> b = a :<|> b
deriving (Typeable, (a :<|> b) -> (a :<|> b) -> Bool
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
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, 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
<$ :: forall a b. a -> (a :<|> b) -> a :<|> a
$c<$ :: forall a a b. a -> (a :<|> b) -> a :<|> a
fmap :: forall a b. (a -> b) -> (a :<|> a) -> a :<|> b
$cfmap :: forall a a b. (a -> b) -> (a :<|> a) -> a :<|> b
Functor, 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 (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a :<|> a) -> f (a :<|> b)
sequence :: forall (m :: * -> *) a. Monad m => (a :<|> m a) -> m (a :<|> a)
$csequence :: forall a (m :: * -> *) a. Monad m => (a :<|> m a) -> m (a :<|> a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(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 :: forall (f :: * -> *) a.
Applicative f =>
(a :<|> f a) -> f (a :<|> a)
$csequenceA :: forall a (f :: * -> *) a.
Applicative f =>
(a :<|> f a) -> f (a :<|> a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a :<|> a) -> f (a :<|> b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> (a :<|> a) -> f (a :<|> b)
Traversable, forall a. (a :<|> a) -> Bool
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 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 :: forall a. Num a => (a :<|> a) -> a
$cproduct :: forall a a. Num a => (a :<|> a) -> a
sum :: forall a. Num a => (a :<|> a) -> a
$csum :: forall a a. Num a => (a :<|> a) -> a
minimum :: forall a. Ord a => (a :<|> a) -> a
$cminimum :: forall a a. Ord a => (a :<|> a) -> a
maximum :: forall a. Ord a => (a :<|> a) -> a
$cmaximum :: forall a a. Ord a => (a :<|> a) -> a
elem :: forall a. Eq a => a -> (a :<|> a) -> Bool
$celem :: forall a a. Eq a => a -> (a :<|> a) -> Bool
length :: forall a. (a :<|> a) -> Int
$clength :: forall a a. (a :<|> a) -> Int
null :: forall a. (a :<|> a) -> Bool
$cnull :: forall a a. (a :<|> a) -> Bool
toList :: forall a. (a :<|> a) -> [a]
$ctoList :: forall a a. (a :<|> a) -> [a]
foldl1 :: forall a. (a -> a -> a) -> (a :<|> a) -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> (a :<|> a) -> a
foldr1 :: forall a. (a -> a -> a) -> (a :<|> a) -> a
$cfoldr1 :: forall a a. (a -> a -> a) -> (a :<|> a) -> a
foldl' :: forall b a. (b -> a -> b) -> b -> (a :<|> a) -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> (a :<|> a) -> b
foldl :: forall b a. (b -> a -> b) -> b -> (a :<|> a) -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> (a :<|> a) -> b
foldr' :: forall a b. (a -> b -> b) -> b -> (a :<|> a) -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> (a :<|> a) -> b
foldr :: forall a b. (a -> b -> b) -> b -> (a :<|> a) -> b
$cfoldr :: forall a a b. (a -> b -> b) -> b -> (a :<|> a) -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> (a :<|> a) -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> (a :<|> a) -> m
foldMap :: forall m a. Monoid m => (a -> m) -> (a :<|> a) -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> (a :<|> a) -> m
fold :: forall m. Monoid m => (a :<|> m) -> m
$cfold :: forall a m. Monoid m => (a :<|> m) -> m
Foldable, 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 :<|> b
b) <> :: (a :<|> b) -> (a :<|> b) -> a :<|> b
<> (a
a' :<|> b
b') = (a
a forall a. Semigroup a => a -> a -> a
<> a
a') forall a b. a -> b -> a :<|> 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 = forall a. Monoid a => a
mempty forall a b. a -> b -> a :<|> b
:<|> forall a. Monoid a => a
mempty
(a
a :<|> b
b) mappend :: (a :<|> b) -> (a :<|> b) -> a :<|> b
`mappend` (a
a' :<|> b
b') = (a
a forall a. Monoid a => a -> a -> a
`mappend` a
a') forall a b. a -> b -> a :<|> b
:<|> (b
b forall a. Monoid a => a -> a -> a
`mappend` b
b')
instance Bifoldable (:<|>) where
bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> (a :<|> b) -> m
bifoldMap a -> m
f b -> m
g ~(a
a :<|> b
b) = a -> m
f a
a forall a. Monoid a => a -> a -> a
`mappend` b -> m
g b
b
instance Bifunctor (:<|>) where
bimap :: forall a b c d. (a -> b) -> (c -> d) -> (a :<|> c) -> b :<|> d
bimap a -> b
f c -> d
g ~(a
a :<|> c
b) = a -> b
f a
a forall a b. a -> b -> a :<|> b
:<|> c -> d
g c
b
instance Biapplicative (:<|>) where
bipure :: forall a b. a -> b -> a :<|> b
bipure = forall a b. a -> b -> a :<|> b
(:<|>)
(a -> b
f :<|> c -> d
g) <<*>> :: forall a b c d. ((a -> b) :<|> (c -> d)) -> (a :<|> c) -> b :<|> d
<<*>> (a
a :<|> c
b) = a -> b
f a
a forall a b. a -> b -> a :<|> b
:<|> c -> d
g c
b
instance Bitraversable (:<|>) where
bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> (a :<|> b) -> f (c :<|> d)
bitraverse a -> f c
f b -> f d
g ~(a
a :<|> b
b) = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 forall a b. a -> b -> a :<|> b
(:<|>) (a -> f c
f a
a) (b -> f d
g b
b)