-- | The @uuid-ossp@ extension provides functions for constructing UUIDs.
--
-- For an example of usage, see the documentation for 'PgExtensionEntity'.
module Database.Beam.Postgres.Extensions.UuidOssp
  ( UuidOssp(..)
  ) where

import           Data.Proxy (Proxy(..))
import           Data.Text (Text)
import           Data.UUID.Types (UUID)

import           Database.Beam
import           Database.Beam.Postgres.Extensions
import           Database.Beam.Postgres.Extensions.Internal

-- | Data type representing definitions contained in the @uuid-ossp@ extension
data UuidOssp = UuidOssp
  { UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidNil ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidNsDns ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidNsUrl ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidNsOid ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidNsX500 ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1 ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1Mc ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
pgUuidGenerateV3 ::
      forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
  , UuidOssp -> forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV4 ::
      forall ctxt s. LiftPg ctxt s UUID
  , UuidOssp -> forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
pgUuidGenerateV5 ::
      forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
  }

instance IsPgExtension UuidOssp where
  pgExtensionName :: Proxy UuidOssp -> Text
pgExtensionName Proxy UuidOssp
Proxy = Text
"uuid-ossp"
  pgExtensionBuild :: UuidOssp
pgExtensionBuild = UuidOssp
    { pgUuidNil :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNil =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_nil" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsDns :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsDns =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_dns" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsUrl :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsUrl =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_url" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsOid :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsOid =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_oid" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsX500 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsX500 =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_x500" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV1 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1 =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v1" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV1Mc :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1Mc =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v1mc" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV3 :: forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
pgUuidGenerateV3 = \(QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
ns) (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
t) ->
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v3" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
ns, Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
t]
    , pgUuidGenerateV4 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV4 =
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v4" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV5 :: forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID)
pgUuidGenerateV5 = \(QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
ns) (QExpr Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
t) ->
        forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr forall a b. (a -> b) -> a -> b
$ forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v5" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
ns, Text
-> Sql92SelectTableExpressionSyntax
     (Sql92SelectSelectTableSyntax
        (Sql92SelectSyntax (BeamSqlBackendSyntax Postgres)))
t]
    }