opaleye-0.6.7004.1: An SQL-generating DSL targeting PostgreSQL

Safe HaskellNone
LanguageHaskell2010

Opaleye

Description

An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to be written within Haskell in a typesafe and composable fashion.

You might like to look at

Synopsis

Documentation

data Nullability Source #

Constructors

NonNullable 
Nullable 
Instances
type A (H HT :: Arr Type (C k2) k2) (C ((,,) h o NN) :: C k2) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H HT :: Arr Type (C k2) k2) (C ((,,) h o NN) :: C k2) = h
type A (H NullsT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H NullsT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) = A (H NullsT :: Arr Type (C a) k2) (C t)
type A (H WT :: Arr Type (TC a) k2) (TC ((,) t Req) :: TC a) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H WT :: Arr Type (TC a) k2) (TC ((,) t Req) :: TC a) = A (H OT :: Arr Type (C a) k2) (C t)
type A (H OT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H OT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) = A (H OT :: Arr Type (C a) k2) (C t)
type A (H HT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H HT :: Arr Type (TC a) k2) (TC ((,) t b) :: TC a) = A (H HT :: Arr Type (C a) k2) (C t)
type A (H WT :: Arr Type (TC a) Type) (TC ((,) t Opt) :: TC a) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H WT :: Arr Type (TC a) Type) (TC ((,) t Opt) :: TC a) = Maybe (A (H OT :: Arr Type (C a) Type) (C t))
type A (H NullsT :: Arr Type (C Type) Type) (C ((,,) h o NN) :: C Type) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H NullsT :: Arr Type (C Type) Type) (C ((,,) h o NN) :: C Type) = Column (Nullable o)
type A (H OT :: Arr Type (C Type) Type) (C ((,,) h o N) :: C Type) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H OT :: Arr Type (C Type) Type) (C ((,,) h o N) :: C Type) = Column (Nullable o)
type A (H OT :: Arr Type (C Type) Type) (C ((,,) h o NN) :: C Type) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H OT :: Arr Type (C Type) Type) (C ((,,) h o NN) :: C Type) = Column o
type A (H HT :: Arr Type (C Type) Type) (C ((,,) h o N) :: C Type) Source # 
Instance details

Defined in Opaleye.Internal.TypeFamilies

type A (H HT :: Arr Type (C Type) Type) (C ((,,) h o N) :: C Type) = Maybe h

type family Field_ (a :: Nullability) b Source #

The name Column will be replaced by Field in version 0.7. The Field_, Field and FieldNullable types exist to help smooth the transition. We recommend that you use Field_, Field or FieldNullable instead of Column everywhere that it is sufficient.

Instances
type Field_ NonNullable a Source # 
Instance details

Defined in Opaleye.Field

type Field_ Nullable a Source # 
Instance details

Defined in Opaleye.Field

data Cursor haskells Source #

Cursor within a transaction.

runSelect Source #

Arguments

:: Default FromFields fields haskells 
=> Connection 
-> Select fields 
-> IO [haskells] 

runSelect's use of the Default typeclass means that the compiler will have trouble inferring types. It is strongly recommended that you provide full type signatures when using runSelect.

Example type specialization:

runSelect :: Select (Field SqlInt4, Field SqlText) -> IO [(Int, String)]

Assuming the makeAdaptorAndInstance splice has been run for the product type Foo:

runSelect :: Select (Foo (Field SqlInt4) (Field SqlText) (Field SqlBool)
          -> IO [Foo Int String Bool]

runSelectTF Source #

Arguments

:: Default FromFields (rec O) (rec H) 
=> Connection 
-> Select (rec O) 
-> IO [rec H] 

runSelectTF has better type inference than runSelect but only works with "higher-kinded data" types.

runSelectFold Source #

Arguments

:: Default FromFields fields haskells 
=> Connection 
-> Select fields 
-> b 
-> (b -> haskells -> IO b) 
-> IO b 

runSelectFold streams the results of a query incrementally and consumes the results with a left fold.

This fold is not strict. The stream consumer is responsible for forcing the evaluation of its result to avoid space leaks.

unsafeFromField :: (b -> b') -> FromField sqlType b -> FromField sqlType' b' Source #

Use unsafeFromField to make an instance to allow you to run queries on your own datatypes. For example:

newtype Foo = Foo Int

instance QueryRunnerColumnDefault Foo Foo where
   defaultFromField = unsafeFromField Foo defaultFromField

It is "unsafe" because it does not check that the sqlType correctly corresponds to the Haskell type.

runSelectExplicit :: FromFields fields haskells -> Connection -> Select fields -> IO [haskells] Source #

runSelectFoldExplicit :: FromFields fields haskells -> Connection -> Select fields -> b -> (b -> haskells -> IO b) -> IO b Source #