{-# language DataKinds #-}
{-# language FlexibleContexts #-}
{-# language FlexibleInstances #-}
{-# language MultiParamTypeClasses #-}
{-# language OverloadedStrings #-}
{-# language StandaloneKindSignatures #-}
{-# language TypeFamilies #-}
{-# language UndecidableInstances #-}
module Rel8.Type.Monoid
( DBMonoid( memptyExpr )
)
where
import Data.Kind ( Constraint, Type )
import Prelude hiding ( null )
import Data.ByteString ( ByteString )
import qualified Data.ByteString.Lazy as Lazy ( ByteString )
import Data.CaseInsensitive ( CI )
import {-# SOURCE #-} Rel8.Expr ( Expr )
import Rel8.Expr.Array ( sempty )
import Rel8.Expr.Serialize ( litExpr )
import Rel8.Schema.Null ( Sql )
import Rel8.Type ( DBType, typeInformation )
import Rel8.Type.Semigroup ( DBSemigroup )
import Data.Text ( Text )
import qualified Data.Text.Lazy as Lazy ( Text )
import Data.Time.LocalTime ( CalendarDiffTime( CalendarDiffTime ) )
type DBMonoid :: Type -> Constraint
class DBSemigroup a => DBMonoid a where
memptyExpr :: Expr a
instance Sql DBType a => DBMonoid [a] where
memptyExpr :: Expr [a]
memptyExpr = TypeInformation (Unnullify a) -> Expr [a]
forall a. TypeInformation (Unnullify a) -> Expr [a]
sempty TypeInformation (Unnullify a)
forall a. DBType a => TypeInformation a
typeInformation
instance DBMonoid CalendarDiffTime where
memptyExpr :: Expr CalendarDiffTime
memptyExpr = CalendarDiffTime -> Expr CalendarDiffTime
forall a. Sql DBType a => a -> Expr a
litExpr (Integer -> NominalDiffTime -> CalendarDiffTime
CalendarDiffTime Integer
0 NominalDiffTime
0)
instance DBMonoid Text where
memptyExpr :: Expr Text
memptyExpr = Text -> Expr Text
forall a. Sql DBType a => a -> Expr a
litExpr Text
""
instance DBMonoid Lazy.Text where
memptyExpr :: Expr Text
memptyExpr = Text -> Expr Text
forall a. Sql DBType a => a -> Expr a
litExpr Text
""
instance DBMonoid (CI Text) where
memptyExpr :: Expr (CI Text)
memptyExpr = CI Text -> Expr (CI Text)
forall a. Sql DBType a => a -> Expr a
litExpr CI Text
""
instance DBMonoid (CI Lazy.Text) where
memptyExpr :: Expr (CI Text)
memptyExpr = CI Text -> Expr (CI Text)
forall a. Sql DBType a => a -> Expr a
litExpr CI Text
""
instance DBMonoid ByteString where
memptyExpr :: Expr ByteString
memptyExpr = ByteString -> Expr ByteString
forall a. Sql DBType a => a -> Expr a
litExpr ByteString
""
instance DBMonoid Lazy.ByteString where
memptyExpr :: Expr ByteString
memptyExpr = ByteString -> Expr ByteString
forall a. Sql DBType a => a -> Expr a
litExpr ByteString
""