{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Opaleye.RunSelect
(
runSelect,
runSelectI,
runSelectFold,
declareCursor,
closeCursor,
foldForward,
unsafeFromField,
runSelectExplicit,
runSelectFoldExplicit,
declareCursorExplicit,
IRQ.Cursor,
IRQ.FromFields,
IRQ.FromField,
IRQ.DefaultFromField(defaultFromField),
IRQ.fromPGSFromField,
IRQ.fromPGSFieldParser,
runSelectTF,
) where
import qualified Database.PostgreSQL.Simple as PGS
import qualified Opaleye.Select as S
import qualified Opaleye.Internal.RunQueryExternal as RQ
import qualified Opaleye.TypeFamilies as TF
import Opaleye.Internal.RunQuery (FromFields)
import qualified Opaleye.Internal.RunQuery as IRQ
import Opaleye.Internal.Inferrable (Inferrable, runInferrable)
import qualified Data.Profunctor.Product.Default as D
runSelect :: D.Default FromFields fields haskells
=> PGS.Connection
-> S.Select fields
-> IO [haskells]
runSelect :: forall fields haskells.
Default FromFields fields haskells =>
Connection -> Select fields -> IO [haskells]
runSelect = forall fields haskells.
Default FromFields fields haskells =>
Connection -> Select fields -> IO [haskells]
RQ.runQuery
{-# DEPRECATED runSelectTF "Use 'runSelectI' instead." #-}
runSelectTF :: D.Default FromFields (rec TF.O) (rec TF.H)
=> PGS.Connection
-> S.Select (rec TF.O)
-> IO [rec TF.H]
runSelectTF :: forall {k2} {k3} (rec :: Arr (*) k2 k3 -> *).
Default FromFields (rec O) (rec H) =>
Connection -> Select (rec O) -> IO [rec H]
runSelectTF = forall fields haskells.
Default FromFields fields haskells =>
Connection -> Select fields -> IO [haskells]
RQ.runQuery
runSelectFold
:: D.Default FromFields fields haskells
=> PGS.Connection
-> S.Select fields
-> b
-> (b -> haskells -> IO b)
-> IO b
runSelectFold :: forall fields haskells b.
Default FromFields fields haskells =>
Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
runSelectFold = forall fields haskells b.
Default FromFields fields haskells =>
Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b
RQ.runQueryFold
declareCursor
:: D.Default FromFields fields haskells
=> PGS.Connection
-> S.Select fields
-> IO (IRQ.Cursor haskells)
declareCursor :: forall fields haskells.
Default FromFields fields haskells =>
Connection -> Select fields -> IO (Cursor haskells)
declareCursor = forall fields haskells.
Default FromFields fields haskells =>
Connection -> Select fields -> IO (Cursor haskells)
RQ.declareCursor
closeCursor :: IRQ.Cursor fields -> IO ()
closeCursor :: forall fields. Cursor fields -> IO ()
closeCursor = forall fields. Cursor fields -> IO ()
RQ.closeCursor
foldForward
:: IRQ.Cursor haskells
-> Int
-> (a -> haskells -> IO a)
-> a
-> IO (Either a a)
foldForward :: forall haskells a.
Cursor haskells
-> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a)
foldForward = forall haskells a.
Cursor haskells
-> Int -> (a -> haskells -> IO a) -> a -> IO (Either a a)
RQ.foldForward
unsafeFromField :: (b -> b')
-> IRQ.FromField sqlType b
-> IRQ.FromField sqlType' b'
unsafeFromField :: forall b b' sqlType sqlType'.
(b -> b') -> FromField sqlType b -> FromField sqlType' b'
unsafeFromField b -> b'
haskellF (IRQ.FromField FieldParser b
fp) =
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap b -> b'
haskellF (forall sqlType haskellType.
FieldParser haskellType -> FromField sqlType haskellType
IRQ.FromField FieldParser b
fp)
runSelectExplicit :: FromFields fields haskells
-> PGS.Connection
-> S.Select fields
-> IO [haskells]
runSelectExplicit :: forall fields haskells.
FromFields fields haskells
-> Connection -> Select fields -> IO [haskells]
runSelectExplicit = forall fields haskells.
FromFields fields haskells
-> Connection -> Select fields -> IO [haskells]
RQ.runQueryExplicit
runSelectFoldExplicit
:: FromFields fields haskells
-> PGS.Connection
-> S.Select fields
-> b
-> (b -> haskells -> IO b)
-> IO b
runSelectFoldExplicit :: forall fields haskells b.
FromFields fields haskells
-> Connection
-> Select fields
-> b
-> (b -> haskells -> IO b)
-> IO b
runSelectFoldExplicit = forall fields haskells b.
FromFields fields haskells
-> Connection
-> Select fields
-> b
-> (b -> haskells -> IO b)
-> IO b
RQ.runQueryFoldExplicit
declareCursorExplicit
:: FromFields fields haskells
-> PGS.Connection
-> S.Select fields
-> IO (IRQ.Cursor haskells)
declareCursorExplicit :: forall fields haskells.
FromFields fields haskells
-> Connection -> Select fields -> IO (Cursor haskells)
declareCursorExplicit = forall fields haskells.
FromFields fields haskells
-> Connection -> Select fields -> IO (Cursor haskells)
RQ.declareCursorExplicit
runSelectI :: (D.Default (Inferrable FromFields) fields haskells)
=> PGS.Connection
-> S.Select fields
-> IO [haskells]
runSelectI :: forall fields haskells.
Default (Inferrable FromFields) fields haskells =>
Connection -> Select fields -> IO [haskells]
runSelectI = forall fields haskells.
FromFields fields haskells
-> Connection -> Select fields -> IO [haskells]
RQ.runQueryExplicit (forall (p :: * -> * -> *) a b. Inferrable p a b -> p a b
runInferrable forall (p :: * -> * -> *) a b. Default p a b => p a b
D.def)