-- | 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 :: (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID))
-> (forall ctxt s. LiftPg ctxt s UUID)
-> (forall ctxt s. LiftPg ctxt s (UUID -> Text -> UUID))
-> UuidOssp
UuidOssp
    { pgUuidNil :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNil =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_nil" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsDns :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsDns =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_dns" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsUrl :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsUrl =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_url" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsOid :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsOid =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_oid" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidNsX500 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidNsX500 =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_ns_x500" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV1 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1 =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v1" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA []
    , pgUuidGenerateV1Mc :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV1Mc =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v1mc" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
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 -> BeamSqlBackendExpressionSyntax Postgres
ns) (QExpr Text -> BeamSqlBackendExpressionSyntax Postgres
t) ->
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v3" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [Text -> BeamSqlBackendExpressionSyntax Postgres
Text -> PgExpressionSyntax
ns, Text -> BeamSqlBackendExpressionSyntax Postgres
Text -> PgExpressionSyntax
t]
    , pgUuidGenerateV4 :: forall ctxt s. LiftPg ctxt s UUID
pgUuidGenerateV4 =
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v4" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
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 -> BeamSqlBackendExpressionSyntax Postgres
ns) (QExpr Text -> BeamSqlBackendExpressionSyntax Postgres
t) ->
        (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall context be s t.
(Text -> BeamSqlBackendExpressionSyntax be)
-> QGenExpr context be s t
QExpr ((Text -> BeamSqlBackendExpressionSyntax Postgres)
 -> QGenExpr ctxt Postgres s UUID)
-> (Text -> BeamSqlBackendExpressionSyntax Postgres)
-> QGenExpr ctxt Postgres s UUID
forall a b. (a -> b) -> a -> b
$ Text -> [PgExpressionSyntax] -> PgExpressionSyntax
forall expr. IsSql99ExpressionSyntax expr => Text -> [expr] -> expr
funcE Text
"uuid_generate_v5" ([PgExpressionSyntax] -> PgExpressionSyntax)
-> (Text -> [PgExpressionSyntax]) -> Text -> PgExpressionSyntax
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text -> PgExpressionSyntax] -> Text -> [PgExpressionSyntax]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA [Text -> BeamSqlBackendExpressionSyntax Postgres
Text -> PgExpressionSyntax
ns, Text -> BeamSqlBackendExpressionSyntax Postgres
Text -> PgExpressionSyntax
t]
    }