opaleye-0.7.3.0: An SQL-generating DSL targeting PostgreSQL
Safe HaskellNone
LanguageHaskell2010

Opaleye.Internal.Table

Synopsis

Documentation

data Table writeFields viewFields Source #

Define a table as follows, where "id", "color", "location", "quantity" and "radius" are the table's fields in Postgres and the types are given in the type signature. The id field is an autoincrementing field (i.e. optional for writes).

data Widget a b c d e = Widget { wid      :: a
                               , color    :: b
                               , location :: c
                               , quantity :: d
                               , radius   :: e }

$(makeAdaptorAndInstance "pWidget" ''Widget)

widgetTable :: Table (Widget (Maybe (Field SqlInt4)) (Field SqlText) (Field SqlText)
                             (Field SqlInt4) (Field SqlFloat8))
                     (Widget (Field SqlText) (Field SqlText) (Field SqlText)
                             (Field SqlInt4) (Field SqlFloat8))
widgetTable = table "widgetTable"
                     (pWidget Widget { wid      = tableField "id"
                                     , color    = tableField "color"
                                     , location = tableField "location"
                                     , quantity = tableField "quantity"
                                     , radius   = tableField "radius" })

The constructors of Table are internal only and will be removed in version 0.8.

Constructors

Table String (TableFields writeFields viewFields)

For unqualified table names. Do not use the constructor. It is considered deprecated and will be removed in version 0.8.

TableWithSchema String String (TableFields writeFields viewFields)

Schema name, table name, table properties. Do not use the constructor. It is considered deprecated and will be removed in version 0.8.

Instances

Instances details
Profunctor Table Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

dimap :: (a -> b) -> (c -> d) -> Table b c -> Table a d #

lmap :: (a -> b) -> Table b c -> Table a c #

rmap :: (b -> c) -> Table a b -> Table a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Table a b -> Table a c #

(.#) :: forall a b c q. Coercible b a => Table b c -> q a b -> Table a c #

Functor (Table a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

fmap :: (a0 -> b) -> Table a a0 -> Table a b #

(<$) :: a0 -> Table a b -> Table a a0 #

tableIdentifier :: Table writeColumns viewColumns -> TableIdentifier Source #

tableColumns :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns Source #

tableProperties :: Table writeColumns viewColumns -> TableFields writeColumns viewColumns Source #

Use tableColumns instead. Will be deprecated soon.

data TableFields writeColumns viewColumns Source #

Constructors

TableFields 

Fields

Instances

Instances details
Profunctor TableFields Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

dimap :: (a -> b) -> (c -> d) -> TableFields b c -> TableFields a d #

lmap :: (a -> b) -> TableFields b c -> TableFields a c #

rmap :: (b -> c) -> TableFields a b -> TableFields a c #

(#.) :: forall a b c q. Coercible c b => q b c -> TableFields a b -> TableFields a c #

(.#) :: forall a b c q. Coercible b a => TableFields b c -> q a b -> TableFields a c #

ProductProfunctor TableFields Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

purePP :: b -> TableFields a b #

(****) :: TableFields a (b -> c) -> TableFields a b -> TableFields a c #

empty :: TableFields () () #

(***!) :: TableFields a b -> TableFields a' b' -> TableFields (a, a') (b, b') #

Functor (TableFields a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

fmap :: (a0 -> b) -> TableFields a a0 -> TableFields a b #

(<$) :: a0 -> TableFields a b -> TableFields a a0 #

Applicative (TableFields a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

pure :: a0 -> TableFields a a0 #

(<*>) :: TableFields a (a0 -> b) -> TableFields a a0 -> TableFields a b #

liftA2 :: (a0 -> b -> c) -> TableFields a a0 -> TableFields a b -> TableFields a c #

(*>) :: TableFields a a0 -> TableFields a b -> TableFields a b #

(<*) :: TableFields a a0 -> TableFields a b -> TableFields a a0 #

type TableColumns = TableFields Source #

Deprecated: Use TableFields instead. TableColumns will be removed in version 0.8.

type TableProperties = TableFields Source #

Deprecated: Use TableFields instead. TableProperties will be removed in version 0.8.

tableColumnsWriter :: TableFields writeColumns viewColumns -> Writer writeColumns viewColumns Source #

tableColumnsView :: TableFields writeColumns viewColumns -> View viewColumns Source #

newtype View columns Source #

Deprecated: Internal only. Do not use. View will be removed in version 0.8.

Constructors

View columns

Deprecated: Internal only. Do not use. View will be removed in version 0.8.

newtype Writer columns dummy Source #

Deprecated: Internal only. Do not use. Writer will be removed in 0.8.

Constructors

Writer (forall f. Functor f => PackMap (f PrimExpr, String) () (f columns) ())

Deprecated: Internal only. Do not use. Writer will be removed in 0.8.

Instances

Instances details
Profunctor Writer Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

dimap :: (a -> b) -> (c -> d) -> Writer b c -> Writer a d #

lmap :: (a -> b) -> Writer b c -> Writer a c #

rmap :: (b -> c) -> Writer a b -> Writer a c #

(#.) :: forall a b c q. Coercible c b => q b c -> Writer a b -> Writer a c #

(.#) :: forall a b c q. Coercible b a => Writer b c -> q a b -> Writer a c #

ProductProfunctor Writer Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

purePP :: b -> Writer a b #

(****) :: Writer a (b -> c) -> Writer a b -> Writer a c #

empty :: Writer () () #

(***!) :: Writer a b -> Writer a' b' -> Writer (a, a') (b, b') #

Functor (Writer a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

fmap :: (a0 -> b) -> Writer a a0 -> Writer a b #

(<$) :: a0 -> Writer a b -> Writer a a0 #

Applicative (Writer a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

pure :: a0 -> Writer a a0 #

(<*>) :: Writer a (a0 -> b) -> Writer a a0 -> Writer a b #

liftA2 :: (a0 -> b -> c) -> Writer a a0 -> Writer a b -> Writer a c #

(*>) :: Writer a a0 -> Writer a b -> Writer a b #

(<*) :: Writer a a0 -> Writer a b -> Writer a a0 #

requiredTableField :: String -> TableFields (Column a) (Column a) Source #

requiredTableField is for fields which are not optional. You must provide them on writes.

optionalTableField :: String -> TableFields (Maybe (Column a)) (Column a) Source #

optionalTableField is for fields that you can omit on writes, such as fields which have defaults or which are SERIAL.

readOnlyTableField :: String -> TableFields () (Column a) Source #

readOnlyTableField is for fields that you must omit on writes, such as SERIAL fields intended to auto-increment only.

required :: String -> TableFields (Column a) (Column a) Source #

Deprecated: Use requiredTableField instead. Will be removed in version 0.8.

optional :: String -> TableFields (Maybe (Column a)) (Column a) Source #

Deprecated: Use optionalTableField instead. Will be removed in version 0.8.

readOnly :: String -> TableFields () (Column a) Source #

Deprecated: Use readOnlyTableField instead. Will be removed in version 0.8.

class TableColumn writeType sqlType | writeType -> sqlType where Source #

Minimal complete definition

tableField

Methods

tableColumn :: String -> TableFields writeType (Column sqlType) Source #

Deprecated: Use tableField instead. Will be removed in 0.8.

tableField :: String -> TableFields writeType (Column sqlType) Source #

Infer either a required (requiredTableField) or optional (optionalTableField) field depending on the write type. It's generally more convenient to use this than required or optional but you do have to provide a type signature instead.

Instances

Instances details
TableColumn (Maybe (Column a)) a Source # 
Instance details

Defined in Opaleye.Internal.Table

TableColumn (Column a) a Source # 
Instance details

Defined in Opaleye.Internal.Table

queryTable :: Unpackspec viewColumns columns -> Table writeColumns viewColumns -> Tag -> (columns, PrimQuery) Source #

runColumnMaker :: Unpackspec tablecolumns columns -> Tag -> tablecolumns -> (columns, [(Symbol, PrimExpr)]) Source #

runWriter :: Writer columns columns' -> columns -> [(PrimExpr, String)] Source #

runWriter' :: Writer columns columns' -> NonEmpty columns -> (NonEmpty [PrimExpr], [String]) Source #

newtype Zip a Source #

Constructors

Zip 

Fields

Instances

Instances details
Semigroup (Zip a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

(<>) :: Zip a -> Zip a -> Zip a #

sconcat :: NonEmpty (Zip a) -> Zip a #

stimes :: Integral b => b -> Zip a -> Zip a #

Monoid (Zip a) Source # 
Instance details

Defined in Opaleye.Internal.Table

Methods

mempty :: Zip a #

mappend :: Zip a -> Zip a -> Zip a #

mconcat :: [Zip a] -> Zip a #