{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE UndecidableInstances #-}
module Database.Beam.Backend.SQL
( module Database.Beam.Backend.SQL.Row
, module Database.Beam.Backend.SQL.SQL2003
, module Database.Beam.Backend.SQL.Types
, MonadBeam(..)
, BeamSqlBackend
, BeamSqlBackendSyntax
, MockSqlBackend
, BeamSqlBackendIsString
, BeamSql99ExpressionBackend
, BeamSql99AggregationBackend
, BeamSql99ConcatExpressionBackend
, BeamSql99CommonTableExpressionBackend
, BeamSql99RecursiveCTEBackend
, BeamSql2003ExpressionBackend
, BeamSqlT021Backend
, BeamSqlT071Backend
, BeamSqlT611Backend
, BeamSqlT612Backend
, BeamSqlT614Backend
, BeamSqlT615Backend
, BeamSqlT616Backend
, BeamSqlT618Backend
, BeamSqlT621Backend
, BeamSql99DataTypeBackend
, BeamSqlBackendSupportsOuterJoin
, BeamSqlBackendSelectSyntax
, BeamSqlBackendInsertSyntax
, BeamSqlBackendInsertValuesSyntax
, BeamSqlBackendUpdateSyntax
, BeamSqlBackendDeleteSyntax
, BeamSqlBackendCastTargetSyntax
, BeamSqlBackendSelectTableSyntax
, BeamSqlBackendAggregationQuantifierSyntax
, BeamSqlBackendSetQuantifierSyntax
, BeamSqlBackendFromSyntax
, BeamSqlBackendTableNameSyntax
, BeamSqlBackendExpressionSyntax
, BeamSqlBackendDataTypeSyntax
, BeamSqlBackendFieldNameSyntax
, BeamSqlBackendExpressionQuantifierSyntax
, BeamSqlBackendValueSyntax
, BeamSqlBackendOrderingSyntax
, BeamSqlBackendGroupingSyntax
, BeamSqlBackendWindowFrameSyntax
, BeamSqlBackendWindowFrameBoundsSyntax
, BeamSqlBackendWindowFrameBoundSyntax
, BeamSql99BackendCTESyntax
, BeamSqlBackendCanSerialize
, BeamSqlBackendCanDeserialize
, BeamSqlBackendSupportsDataType
) where
import Database.Beam.Backend.SQL.SQL2003
import Database.Beam.Backend.SQL.Row
import Database.Beam.Backend.SQL.Types
import Database.Beam.Backend.Types
import Control.Monad.Cont
import Control.Monad.Except
import qualified Control.Monad.RWS.Lazy as Lazy
import qualified Control.Monad.RWS.Strict as Strict
import Control.Monad.Reader
import qualified Control.Monad.State.Lazy as Lazy
import qualified Control.Monad.Writer.Lazy as Lazy
import qualified Control.Monad.State.Strict as Strict
import qualified Control.Monad.Writer.Strict as Strict
import Data.Kind (Type)
import Data.Tagged (Tagged)
import Data.Text (Text)
class (BeamBackend be, Monad m) =>
MonadBeam be m | m -> be where
{-# MINIMAL runReturningMany #-}
runReturningMany :: FromBackendRow be x
=> BeamSqlBackendSyntax be
-> (m (Maybe x) -> m a)
-> m a
runNoReturn :: BeamSqlBackendSyntax be -> m ()
runNoReturn BeamSqlBackendSyntax be
cmd =
BeamSqlBackendSyntax be -> (m (Maybe ()) -> m ()) -> m ()
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
cmd ((m (Maybe ()) -> m ()) -> m ()) -> (m (Maybe ()) -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \(m (Maybe ())
_ :: m (Maybe ())) -> () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
runReturningOne :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne BeamSqlBackendSyntax be
cmd =
BeamSqlBackendSyntax be
-> (m (Maybe x) -> m (Maybe x)) -> m (Maybe x)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
cmd ((m (Maybe x) -> m (Maybe x)) -> m (Maybe x))
-> (m (Maybe x) -> m (Maybe x)) -> m (Maybe x)
forall a b. (a -> b) -> a -> b
$ \m (Maybe x)
next ->
do Maybe x
a <- m (Maybe x)
next
case Maybe x
a of
Maybe x
Nothing -> Maybe x -> m (Maybe x)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe x
forall a. Maybe a
Nothing
Just x
x -> do
Maybe x
a' <- m (Maybe x)
next
case Maybe x
a' of
Maybe x
Nothing -> Maybe x -> m (Maybe x)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (x -> Maybe x
forall a. a -> Maybe a
Just x
x)
Just x
_ -> Maybe x -> m (Maybe x)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe x
forall a. Maybe a
Nothing
runReturningList :: FromBackendRow be x => BeamSqlBackendSyntax be -> m [x]
runReturningList BeamSqlBackendSyntax be
cmd =
BeamSqlBackendSyntax be -> (m (Maybe x) -> m [x]) -> m [x]
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
cmd ((m (Maybe x) -> m [x]) -> m [x])
-> (m (Maybe x) -> m [x]) -> m [x]
forall a b. (a -> b) -> a -> b
$ \m (Maybe x)
next ->
let collectM :: ([x] -> [x]) -> m [x]
collectM [x] -> [x]
acc = do
Maybe x
a <- m (Maybe x)
next
case Maybe x
a of
Maybe x
Nothing -> [x] -> m [x]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([x] -> [x]
acc [])
Just x
x -> ([x] -> [x]) -> m [x]
collectM ([x] -> [x]
acc ([x] -> [x]) -> ([x] -> [x]) -> [x] -> [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (x
xx -> [x] -> [x]
forall a. a -> [a] -> [a]
:))
in ([x] -> [x]) -> m [x]
collectM [x] -> [x]
forall a. a -> a
id
instance MonadBeam be m => MonadBeam be (ExceptT e m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (ExceptT e m (Maybe x) -> ExceptT e m a) -> ExceptT e m a
runReturningMany BeamSqlBackendSyntax be
s ExceptT e m (Maybe x) -> ExceptT e m a
a = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ BeamSqlBackendSyntax be
-> (m (Maybe x) -> m (Either e a)) -> m (Either e a)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> ExceptT e m a -> m (Either e a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT (ExceptT e m (Maybe x) -> ExceptT e m a
a (m (Maybe x) -> ExceptT e m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)))
runNoReturn :: BeamSqlBackendSyntax be -> ExceptT e m ()
runNoReturn = m () -> ExceptT e m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT e m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> ExceptT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> ExceptT e m (Maybe x)
runReturningOne = m (Maybe x) -> ExceptT e m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> ExceptT e m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> ExceptT e m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> ExceptT e m [x]
runReturningList = m [x] -> ExceptT e m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> ExceptT e m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> ExceptT e m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance MonadBeam be m => MonadBeam be (ContT r m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (ContT r m (Maybe x) -> ContT r m a) -> ContT r m a
runReturningMany BeamSqlBackendSyntax be
s ContT r m (Maybe x) -> ContT r m a
a = ((a -> m r) -> m r) -> ContT r m a
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((a -> m r) -> m r) -> ContT r m a)
-> ((a -> m r) -> m r) -> ContT r m a
forall a b. (a -> b) -> a -> b
$ \a -> m r
r ->
BeamSqlBackendSyntax be -> (m (Maybe x) -> m r) -> m r
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> ContT r m a -> (a -> m r) -> m r
forall k (r :: k) (m :: k -> *) a. ContT r m a -> (a -> m r) -> m r
runContT (ContT r m (Maybe x) -> ContT r m a
a (m (Maybe x) -> ContT r m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) a -> m r
r)
runNoReturn :: BeamSqlBackendSyntax be -> ContT r m ()
runNoReturn = m () -> ContT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ContT r m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> ContT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> ContT r m (Maybe x)
runReturningOne = m (Maybe x) -> ContT r m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> ContT r m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> ContT r m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> ContT r m [x]
runReturningList = m [x] -> ContT r m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> ContT r m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> ContT r m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance MonadBeam be m => MonadBeam be (ReaderT r m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (ReaderT r m (Maybe x) -> ReaderT r m a) -> ReaderT r m a
runReturningMany BeamSqlBackendSyntax be
s ReaderT r m (Maybe x) -> ReaderT r m a
a = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ \r
r ->
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> ReaderT r m a -> r -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (ReaderT r m (Maybe x) -> ReaderT r m a
a (m (Maybe x) -> ReaderT r m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) r
r)
runNoReturn :: BeamSqlBackendSyntax be -> ReaderT r m ()
runNoReturn = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> ReaderT r m (Maybe x)
runReturningOne = m (Maybe x) -> ReaderT r m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> ReaderT r m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> ReaderT r m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> ReaderT r m [x]
runReturningList = m [x] -> ReaderT r m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> ReaderT r m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> ReaderT r m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance MonadBeam be m => MonadBeam be (Lazy.StateT s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (StateT s m (Maybe x) -> StateT s m a) -> StateT s m a
runReturningMany BeamSqlBackendSyntax be
s StateT s m (Maybe x) -> StateT s m a
a = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Lazy.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
st ->
BeamSqlBackendSyntax be -> (m (Maybe x) -> m (a, s)) -> m (a, s)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Lazy.runStateT (StateT s m (Maybe x) -> StateT s m a
a (m (Maybe x) -> StateT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) s
st)
runNoReturn :: BeamSqlBackendSyntax be -> StateT s m ()
runNoReturn = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> StateT s m (Maybe x)
runReturningOne = m (Maybe x) -> StateT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> StateT s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> StateT s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> StateT s m [x]
runReturningList = m [x] -> StateT s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> StateT s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> StateT s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance MonadBeam be m => MonadBeam be (Strict.StateT s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (StateT s m (Maybe x) -> StateT s m a) -> StateT s m a
runReturningMany BeamSqlBackendSyntax be
s StateT s m (Maybe x) -> StateT s m a
a = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
Strict.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
st ->
BeamSqlBackendSyntax be -> (m (Maybe x) -> m (a, s)) -> m (a, s)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> StateT s m a -> s -> m (a, s)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
Strict.runStateT (StateT s m (Maybe x) -> StateT s m a
a (m (Maybe x) -> StateT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) s
st)
runNoReturn :: BeamSqlBackendSyntax be -> StateT s m ()
runNoReturn = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> StateT s m (Maybe x)
runReturningOne = m (Maybe x) -> StateT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> StateT s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> StateT s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> StateT s m [x]
runReturningList = m [x] -> StateT s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> StateT s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> StateT s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance (MonadBeam be m, Monoid s) => MonadBeam be (Lazy.WriterT s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (WriterT s m (Maybe x) -> WriterT s m a) -> WriterT s m a
runReturningMany BeamSqlBackendSyntax be
s WriterT s m (Maybe x) -> WriterT s m a
a = m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Lazy.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$
BeamSqlBackendSyntax be -> (m (Maybe x) -> m (a, s)) -> m (a, s)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> WriterT s m a -> m (a, s)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Lazy.runWriterT (WriterT s m (Maybe x) -> WriterT s m a
a (m (Maybe x) -> WriterT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)))
runNoReturn :: BeamSqlBackendSyntax be -> WriterT s m ()
runNoReturn = m () -> WriterT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> WriterT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> WriterT s m (Maybe x)
runReturningOne = m (Maybe x) -> WriterT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> WriterT s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> WriterT s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> WriterT s m [x]
runReturningList = m [x] -> WriterT s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> WriterT s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> WriterT s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance (MonadBeam be m, Monoid s) => MonadBeam be (Strict.WriterT s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (WriterT s m (Maybe x) -> WriterT s m a) -> WriterT s m a
runReturningMany BeamSqlBackendSyntax be
s WriterT s m (Maybe x) -> WriterT s m a
a = m (a, s) -> WriterT s m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
Strict.WriterT (m (a, s) -> WriterT s m a) -> m (a, s) -> WriterT s m a
forall a b. (a -> b) -> a -> b
$
BeamSqlBackendSyntax be -> (m (Maybe x) -> m (a, s)) -> m (a, s)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> WriterT s m a -> m (a, s)
forall w (m :: * -> *) a. WriterT w m a -> m (a, w)
Strict.runWriterT (WriterT s m (Maybe x) -> WriterT s m a
a (m (Maybe x) -> WriterT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)))
runNoReturn :: BeamSqlBackendSyntax be -> WriterT s m ()
runNoReturn = m () -> WriterT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> WriterT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> WriterT s m (Maybe x)
runReturningOne = m (Maybe x) -> WriterT s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> WriterT s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> WriterT s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> WriterT s m [x]
runReturningList = m [x] -> WriterT s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> WriterT s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> WriterT s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance (MonadBeam be m, Monoid w) => MonadBeam be (Lazy.RWST r w s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (RWST r w s m (Maybe x) -> RWST r w s m a) -> RWST r w s m a
runReturningMany BeamSqlBackendSyntax be
s RWST r w s m (Maybe x) -> RWST r w s m a
a = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Lazy.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
st ->
BeamSqlBackendSyntax be
-> (m (Maybe x) -> m (a, s, w)) -> m (a, s, w)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> RWST r w s m a -> r -> s -> m (a, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Lazy.runRWST (RWST r w s m (Maybe x) -> RWST r w s m a
a (m (Maybe x) -> RWST r w s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) r
r s
st)
runNoReturn :: BeamSqlBackendSyntax be -> RWST r w s m ()
runNoReturn = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> RWST r w s m (Maybe x)
runReturningOne = m (Maybe x) -> RWST r w s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> RWST r w s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> RWST r w s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> RWST r w s m [x]
runReturningList = m [x] -> RWST r w s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> RWST r w s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> RWST r w s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
instance (MonadBeam be m, Monoid w) => MonadBeam be (Strict.RWST r w s m) where
runReturningMany :: BeamSqlBackendSyntax be
-> (RWST r w s m (Maybe x) -> RWST r w s m a) -> RWST r w s m a
runReturningMany BeamSqlBackendSyntax be
s RWST r w s m (Maybe x) -> RWST r w s m a
a = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
Strict.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
st ->
BeamSqlBackendSyntax be
-> (m (Maybe x) -> m (a, s, w)) -> m (a, s, w)
forall be (m :: * -> *) x a.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> (m (Maybe x) -> m a) -> m a
runReturningMany BeamSqlBackendSyntax be
s (\m (Maybe x)
nextRow -> RWST r w s m a -> r -> s -> m (a, s, w)
forall r w s (m :: * -> *) a.
RWST r w s m a -> r -> s -> m (a, s, w)
Strict.runRWST (RWST r w s m (Maybe x) -> RWST r w s m a
a (m (Maybe x) -> RWST r w s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Maybe x)
nextRow)) r
r s
st)
runNoReturn :: BeamSqlBackendSyntax be -> RWST r w s m ()
runNoReturn = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ())
-> (BeamSqlBackendSyntax be -> m ())
-> BeamSqlBackendSyntax be
-> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m ()
forall be (m :: * -> *).
MonadBeam be m =>
BeamSqlBackendSyntax be -> m ()
runNoReturn
runReturningOne :: BeamSqlBackendSyntax be -> RWST r w s m (Maybe x)
runReturningOne = m (Maybe x) -> RWST r w s m (Maybe x)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Maybe x) -> RWST r w s m (Maybe x))
-> (BeamSqlBackendSyntax be -> m (Maybe x))
-> BeamSqlBackendSyntax be
-> RWST r w s m (Maybe x)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m (Maybe x)
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m (Maybe x)
runReturningOne
runReturningList :: BeamSqlBackendSyntax be -> RWST r w s m [x]
runReturningList = m [x] -> RWST r w s m [x]
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m [x] -> RWST r w s m [x])
-> (BeamSqlBackendSyntax be -> m [x])
-> BeamSqlBackendSyntax be
-> RWST r w s m [x]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. BeamSqlBackendSyntax be -> m [x]
forall be (m :: * -> *) x.
(MonadBeam be m, FromBackendRow be x) =>
BeamSqlBackendSyntax be -> m [x]
runReturningList
class (
BeamBackend be
, IsSql92Syntax (BeamSqlBackendSyntax be)
, Sql92SanityCheck (BeamSqlBackendSyntax be)
, HasSqlValueSyntax (BeamSqlBackendValueSyntax be) Bool
, HasSqlValueSyntax (BeamSqlBackendValueSyntax be) SqlNull
, Eq (BeamSqlBackendExpressionSyntax be)
) => BeamSqlBackend be
type family BeamSqlBackendSyntax be :: Type
data MockSqlBackend syntax
class Trivial a
instance Trivial a
instance BeamBackend (MockSqlBackend syntax) where
type BackendFromField (MockSqlBackend syntax) = Trivial
instance ( IsSql92Syntax syntax
, Sql92SanityCheck syntax
, HasSqlValueSyntax (Sql92ValueSyntax syntax) Bool
, HasSqlValueSyntax (Sql92ValueSyntax syntax) SqlNull
, Eq (Sql92ExpressionSyntax syntax)
) => BeamSqlBackend (MockSqlBackend syntax)
type instance BeamSqlBackendSyntax (MockSqlBackend syntax) = syntax
class BeamSqlBackendIsString be text
instance BeamSqlBackendIsString be t => BeamSqlBackendIsString be (Tagged tag t)
instance BeamSqlBackendIsString (MockSqlBackend cmd) Text
instance BeamSqlBackendIsString (MockSqlBackend cmd) [Char]
type BeamSql99ExpressionBackend be = IsSql99ExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSql99ConcatExpressionBackend be = IsSql99ConcatExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSql99CommonTableExpressionBackend be =
( BeamSqlBackend be
, IsSql99CommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be)
, IsSql99CommonTableExpressionSyntax (BeamSql99BackendCTESyntax be)
, Sql99CTESelectSyntax (BeamSql99BackendCTESyntax be) ~ BeamSqlBackendSelectSyntax be )
type BeamSql99RecursiveCTEBackend be=
( BeamSql99CommonTableExpressionBackend be
, IsSql99RecursiveCommonTableExpressionSelectSyntax (BeamSqlBackendSelectSyntax be) )
type BeamSql99AggregationBackend be = IsSql99AggregationExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSql2003ExpressionBackend be = ( IsSql2003ExpressionSyntax (BeamSqlBackendExpressionSyntax be)
, Sql2003SanityCheck (BeamSqlBackendSyntax be) )
type BeamSqlBackendSupportsOuterJoin be = IsSql92FromOuterJoinSyntax (BeamSqlBackendFromSyntax be)
type BeamSqlT021Backend be = IsSql2003BinaryAndVarBinaryDataTypeSyntax (BeamSqlBackendCastTargetSyntax be)
type BeamSqlT071Backend be = IsSql2008BigIntDataTypeSyntax (BeamSqlBackendCastTargetSyntax be)
type BeamSqlT611Backend be = IsSql2003ExpressionElementaryOLAPOperationsSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT612Backend be = IsSql2003ExpressionAdvancedOLAPOperationsSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT614Backend be = IsSql2003NtileExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT615Backend be = IsSql2003LeadAndLagExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT616Backend be = IsSql2003FirstValueAndLastValueExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT618Backend be = IsSql2003NthValueExpressionSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlT621Backend be =
( IsSql2003EnhancedNumericFunctionsExpressionSyntax (BeamSqlBackendExpressionSyntax be)
, IsSql2003EnhancedNumericFunctionsAggregationExpressionSyntax (BeamSqlBackendExpressionSyntax be) )
type BeamSql99DataTypeBackend be =
( BeamSqlBackend be
, IsSql99DataTypeSyntax (BeamSqlBackendCastTargetSyntax be) )
type BeamSqlBackendSelectSyntax be = Sql92SelectSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendInsertSyntax be = Sql92InsertSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendInsertValuesSyntax be = Sql92InsertValuesSyntax (BeamSqlBackendInsertSyntax be)
type BeamSqlBackendExpressionSyntax be = Sql92ExpressionSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendDataTypeSyntax be = Sql92ExpressionCastTargetSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlBackendFieldNameSyntax be = Sql92ExpressionFieldNameSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlBackendUpdateSyntax be = Sql92UpdateSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendDeleteSyntax be = Sql92DeleteSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendCastTargetSyntax be
= Sql92ExpressionCastTargetSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlBackendExpressionQuantifierSyntax be = Sql92ExpressionQuantifierSyntax (Sql92ExpressionSyntax (BeamSqlBackendSyntax be))
type BeamSqlBackendValueSyntax be = Sql92ValueSyntax (BeamSqlBackendSyntax be)
type BeamSqlBackendSetQuantifierSyntax be = Sql92SelectTableSetQuantifierSyntax (BeamSqlBackendSelectTableSyntax be)
type BeamSqlBackendAggregationQuantifierSyntax be = Sql92AggregationSetQuantifierSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlBackendSelectTableSyntax be = Sql92SelectSelectTableSyntax (BeamSqlBackendSelectSyntax be)
type BeamSqlBackendFromSyntax be = Sql92SelectFromSyntax (BeamSqlBackendSelectSyntax be)
type BeamSqlBackendTableNameSyntax be = Sql92TableSourceTableNameSyntax (Sql92FromTableSourceSyntax (BeamSqlBackendFromSyntax be))
type BeamSqlBackendOrderingSyntax be = Sql92SelectOrderingSyntax (BeamSqlBackendSelectSyntax be)
type BeamSqlBackendGroupingSyntax be = Sql92SelectTableGroupingSyntax (BeamSqlBackendSelectTableSyntax be)
type BeamSqlBackendWindowFrameSyntax be = Sql2003ExpressionWindowFrameSyntax (BeamSqlBackendExpressionSyntax be)
type BeamSqlBackendWindowFrameBoundsSyntax be = Sql2003WindowFrameBoundsSyntax (BeamSqlBackendWindowFrameSyntax be)
type BeamSqlBackendWindowFrameBoundSyntax be = Sql2003WindowFrameBoundsBoundSyntax (BeamSqlBackendWindowFrameBoundsSyntax be)
type BeamSql99BackendCTESyntax be = Sql99SelectCTESyntax (BeamSqlBackendSelectSyntax be)
type BeamSqlBackendCanSerialize be = HasSqlValueSyntax (BeamSqlBackendValueSyntax be)
type BeamSqlBackendCanDeserialize be = FromBackendRow be
type BeamSqlBackendSupportsDataType be x =
( BeamSqlBackendCanDeserialize be x
, BeamSqlBackendCanSerialize be x )