module PostgresqlSyntax.Ast.FuncApplication where
import PostgresqlSyntax.Algebra
import PostgresqlSyntax.Ast.FuncApplicationParams
import PostgresqlSyntax.Ast.FuncName
import qualified PostgresqlSyntax.Helpers.Gens as Gens
import qualified PostgresqlSyntax.Helpers.Parsers as Parsers
import PostgresqlSyntax.Prelude
import qualified Test.QuickCheck as Qc
data FuncApplication = FuncApplication FuncName (Maybe FuncApplicationParams)
deriving (Int -> FuncApplication -> ShowS
[FuncApplication] -> ShowS
FuncApplication -> String
(Int -> FuncApplication -> ShowS)
-> (FuncApplication -> String)
-> ([FuncApplication] -> ShowS)
-> Show FuncApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FuncApplication -> ShowS
showsPrec :: Int -> FuncApplication -> ShowS
$cshow :: FuncApplication -> String
show :: FuncApplication -> String
$cshowList :: [FuncApplication] -> ShowS
showList :: [FuncApplication] -> ShowS
Show, (forall x. FuncApplication -> Rep FuncApplication x)
-> (forall x. Rep FuncApplication x -> FuncApplication)
-> Generic FuncApplication
forall x. Rep FuncApplication x -> FuncApplication
forall x. FuncApplication -> Rep FuncApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. FuncApplication -> Rep FuncApplication x
from :: forall x. FuncApplication -> Rep FuncApplication x
$cto :: forall x. Rep FuncApplication x -> FuncApplication
to :: forall x. Rep FuncApplication x -> FuncApplication
Generic, FuncApplication -> FuncApplication -> Bool
(FuncApplication -> FuncApplication -> Bool)
-> (FuncApplication -> FuncApplication -> Bool)
-> Eq FuncApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FuncApplication -> FuncApplication -> Bool
== :: FuncApplication -> FuncApplication -> Bool
$c/= :: FuncApplication -> FuncApplication -> Bool
/= :: FuncApplication -> FuncApplication -> Bool
Eq, Eq FuncApplication
Eq FuncApplication =>
(FuncApplication -> FuncApplication -> Ordering)
-> (FuncApplication -> FuncApplication -> Bool)
-> (FuncApplication -> FuncApplication -> Bool)
-> (FuncApplication -> FuncApplication -> Bool)
-> (FuncApplication -> FuncApplication -> Bool)
-> (FuncApplication -> FuncApplication -> FuncApplication)
-> (FuncApplication -> FuncApplication -> FuncApplication)
-> Ord FuncApplication
FuncApplication -> FuncApplication -> Bool
FuncApplication -> FuncApplication -> Ordering
FuncApplication -> FuncApplication -> FuncApplication
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: FuncApplication -> FuncApplication -> Ordering
compare :: FuncApplication -> FuncApplication -> Ordering
$c< :: FuncApplication -> FuncApplication -> Bool
< :: FuncApplication -> FuncApplication -> Bool
$c<= :: FuncApplication -> FuncApplication -> Bool
<= :: FuncApplication -> FuncApplication -> Bool
$c> :: FuncApplication -> FuncApplication -> Bool
> :: FuncApplication -> FuncApplication -> Bool
$c>= :: FuncApplication -> FuncApplication -> Bool
>= :: FuncApplication -> FuncApplication -> Bool
$cmax :: FuncApplication -> FuncApplication -> FuncApplication
max :: FuncApplication -> FuncApplication -> FuncApplication
$cmin :: FuncApplication -> FuncApplication -> FuncApplication
min :: FuncApplication -> FuncApplication -> FuncApplication
Ord, Typeable FuncApplication
Typeable FuncApplication =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FuncApplication -> c FuncApplication)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FuncApplication)
-> (FuncApplication -> Constr)
-> (FuncApplication -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FuncApplication))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FuncApplication))
-> ((forall b. Data b => b -> b)
-> FuncApplication -> FuncApplication)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r)
-> (forall u.
(forall d. Data d => d -> u) -> FuncApplication -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> FuncApplication -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication)
-> Data FuncApplication
FuncApplication -> Constr
FuncApplication -> DataType
(forall b. Data b => b -> b) -> FuncApplication -> FuncApplication
forall a.
Typeable a =>
(forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> FuncApplication -> u
forall u. (forall d. Data d => d -> u) -> FuncApplication -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FuncApplication
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FuncApplication -> c FuncApplication
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FuncApplication)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FuncApplication)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FuncApplication -> c FuncApplication
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> FuncApplication -> c FuncApplication
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FuncApplication
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c FuncApplication
$ctoConstr :: FuncApplication -> Constr
toConstr :: FuncApplication -> Constr
$cdataTypeOf :: FuncApplication -> DataType
dataTypeOf :: FuncApplication -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FuncApplication)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c FuncApplication)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FuncApplication)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c FuncApplication)
$cgmapT :: (forall b. Data b => b -> b) -> FuncApplication -> FuncApplication
gmapT :: (forall b. Data b => b -> b) -> FuncApplication -> FuncApplication
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> FuncApplication -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> FuncApplication -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> FuncApplication -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> FuncApplication -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> FuncApplication -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> FuncApplication -> m FuncApplication
Data)
instance IsAst FuncApplication where
toTextBuilder :: Settings -> FuncApplication -> TextBuilder
toTextBuilder Settings
settings (FuncApplication FuncName
a Maybe FuncApplicationParams
b) = Settings -> FuncName -> TextBuilder
forall a. IsAst a => Settings -> a -> TextBuilder
toTextBuilder Settings
settings FuncName
a TextBuilder -> TextBuilder -> TextBuilder
forall a. Semigroup a => a -> a -> a
<> TextBuilder
"(" TextBuilder -> TextBuilder -> TextBuilder
forall a. Semigroup a => a -> a -> a
<> (FuncApplicationParams -> TextBuilder)
-> Maybe FuncApplicationParams -> TextBuilder
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Settings -> FuncApplicationParams -> TextBuilder
forall a. IsAst a => Settings -> a -> TextBuilder
toTextBuilder Settings
settings) Maybe FuncApplicationParams
b TextBuilder -> TextBuilder -> TextBuilder
forall a. Semigroup a => a -> a -> a
<> TextBuilder
")"
parser :: Settings -> Parser FuncApplication
parser Settings
settings =
HeadedParsec Void Text Char -> HeadedParsec Void Text ()
forall err strm a.
(Ord err, Stream strm) =>
HeadedParsec err strm a -> HeadedParsec err strm ()
Parsers.notFollowedBy (Text -> HeadedParsec Void Text Text
forall {s} {e}.
(Tokens s ~ Text, Token s ~ Char, Ord e, Stream s) =>
Text -> HeadedParsec e s Text
Parsers.keyword Text
"operator" HeadedParsec Void Text Text
-> HeadedParsec Void Text () -> HeadedParsec Void Text ()
forall a b.
HeadedParsec Void Text a
-> HeadedParsec Void Text b -> HeadedParsec Void Text b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> HeadedParsec Void Text ()
forall err strm.
(Ord err, Stream strm, Token strm ~ Char) =>
HeadedParsec err strm ()
Parsers.space HeadedParsec Void Text ()
-> HeadedParsec Void Text Char -> HeadedParsec Void Text Char
forall a b.
HeadedParsec Void Text a
-> HeadedParsec Void Text b -> HeadedParsec Void Text b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Char -> HeadedParsec Void Text Char
forall err strm.
(Ord err, Stream strm, Token strm ~ Char) =>
Char -> HeadedParsec err strm Char
Parsers.char Char
'(')
HeadedParsec Void Text ()
-> Parser FuncApplication -> Parser FuncApplication
forall a b.
HeadedParsec Void Text a
-> HeadedParsec Void Text b -> HeadedParsec Void Text b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (FuncName -> Maybe FuncApplicationParams -> FuncApplication)
-> Parser FuncName
-> Parser (Maybe FuncApplicationParams)
-> Parser FuncApplication
forall label content result.
(label -> content -> result)
-> Parser label -> Parser content -> Parser result
Parsers.inParensWithLabel FuncName -> Maybe FuncApplicationParams -> FuncApplication
FuncApplication (Settings -> Parser FuncName
forall a. IsAst a => Settings -> Parser a
parser Settings
settings) (HeadedParsec Void Text FuncApplicationParams
-> Parser (Maybe FuncApplicationParams)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Settings -> HeadedParsec Void Text FuncApplicationParams
forall a. IsAst a => Settings -> Parser a
parser Settings
settings))
instance Qc.Arbitrary FuncApplication where
shrink :: FuncApplication -> [FuncApplication]
shrink = FuncApplication -> [FuncApplication]
forall a.
(Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) =>
a -> [a]
Qc.genericShrink
arbitrary :: Gen FuncApplication
arbitrary = FuncName -> Maybe FuncApplicationParams -> FuncApplication
FuncApplication (FuncName -> Maybe FuncApplicationParams -> FuncApplication)
-> Gen FuncName
-> Gen (Maybe FuncApplicationParams -> FuncApplication)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen FuncName
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe FuncApplicationParams -> FuncApplication)
-> Gen (Maybe FuncApplicationParams) -> Gen FuncApplication
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen FuncApplicationParams -> Gen (Maybe FuncApplicationParams)
forall a. Gen a -> Gen (Maybe a)
Gens.terminatingMaybe Gen FuncApplicationParams
forall a. Arbitrary a => Gen a
arbitrary