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

Opaleye.ToFields

Synopsis

Creating Fields from Haskell values

toFields :: Default ToFields haskells fields => haskells -> fields Source #

toFields provides a convenient typeclass wrapper around the Field_ creation functions in Opaleye.SqlTypes. Besides convenience it doesn't provide any additional functionality.

It can be used with functions like runInsert to insert custom Haskell types into the database. The following is an example of a function for inserting custom types.

  customInsert
     :: ( Default ToFields haskells fields )
     => Connection
     -> Table fields fields'
     -> [haskells]
     -> IO Int64
  customInsert conn table haskells = runInsert_ conn Insert {
        iTable      = table
      , iRows       = map toFields haskells
      , iReturning  = rCount
      , iOnConflict = Nothing
    }

In order to use this function with your custom types, you need to define an instance of Default ToFields for your custom types.

toFieldsI Source #

Arguments

:: Default (Inferrable ToFields) haskells fields 
=> haskells 
-> fields 

Version of toFields with better type inference

Creating ToFields

toToFields :: (haskells -> fields) -> ToFields haskells fields Source #

Explicit versions

toFieldsExplicit :: ToFields haskells fields -> haskells -> fields Source #

Adaptor

data ToFields haskells fields Source #

Instances

Instances details
Profunctor ToFields Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

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

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

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

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

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

ProductProfunctor ToFields Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

purePP :: b -> ToFields a b #

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

empty :: ToFields () () #

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

SumProfunctor ToFields Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

(+++!) :: ToFields a b -> ToFields a' b' -> ToFields (Either a a') (Either b b') #

Default ToFields Bool (Column SqlBool) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Double (Column SqlFloat8) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int (Column SqlInt4) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int32 (Column SqlInt4) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Int64 (Column SqlInt8) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlBytea) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ByteString (Column SqlBytea) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Scientific (Column SqlNumeric) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields String (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Text (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields UTCTime (Column SqlTimestamptz) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Value (Column SqlJsonb) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Value (Column SqlJson) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Text (Column SqlText) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields ZonedTime (Column SqlTimestamptz) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields LocalTime (Column SqlTimestamp) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields TimeOfDay (Column SqlTime) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields Day (Column SqlDate) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields UUID (Column SqlUuid) Source # 
Instance details

Defined in Opaleye.Internal.Constant

(Default ToFields a (Column b), IsSqlType b) => Default ToFields [a] (Column (SqlArray b)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields [a] (Column (SqlArray b)) #

Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Maybe (Column sql)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Maybe haskell) (Maybe (Column sql)) #

Default ToFields haskell (Column sql) => Default ToFields (Maybe haskell) (Column (Nullable sql)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Maybe haskell) (Column (Nullable sql)) #

(Default ToFields a b, Default Nullspec a b) => Default ToFields (Maybe a) (MaybeFields b) Source # 
Instance details

Defined in Opaleye.Internal.MaybeFields

Methods

def :: ToFields (Maybe a) (MaybeFields b) #

Default ToFields (CI Text) (Column SqlCitext) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (CI Text) (Column SqlCitext) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Int) (Column (SqlRange SqlInt4)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Int64) (Column (SqlRange SqlInt8)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Scientific) (Column (SqlRange SqlNumeric)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange UTCTime) (Column (SqlRange SqlTimestamptz)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange LocalTime) (Column (SqlRange SqlTimestamp)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (PGRange Day) (Column (SqlRange SqlDate)) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Default ToFields (Column a) (Column a) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

def :: ToFields (Column a) (Column a) #

Functor (ToFields a) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

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

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

Applicative (ToFields a) Source # 
Instance details

Defined in Opaleye.Internal.Constant

Methods

pure :: a0 -> ToFields a a0 #

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

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

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

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

Column SqlBool ~ cSqlBool => Default (Inferrable ToFields) Bool cSqlBool Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Bool cSqlBool #

Column SqlFloat8 ~ cSqlFloat8 => Default (Inferrable ToFields) Double cSqlFloat8 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Double cSqlFloat8 #

Column SqlInt4 ~ cSqlInt4 => Default (Inferrable ToFields) Int cSqlInt4 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Int cSqlInt4 #

Column SqlInt4 ~ cSqlInt4 => Default (Inferrable ToFields) Int32 cSqlInt4 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Int32 cSqlInt4 #

Column SqlInt8 ~ cSqlInt8 => Default (Inferrable ToFields) Int64 cSqlInt8 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Int64 cSqlInt8 #

Column SqlBytea ~ cSqlBytea => Default (Inferrable ToFields) ByteString cSqlBytea Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields ByteString cSqlBytea #

Column SqlBytea ~ cSqlBytea => Default (Inferrable ToFields) ByteString cSqlBytea Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields ByteString cSqlBytea #

Column SqlNumeric ~ cSqlNumeric => Default (Inferrable ToFields) Scientific cSqlNumeric Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Scientific cSqlNumeric #

Column SqlText ~ cSqlText => Default (Inferrable ToFields) String cSqlText Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields String cSqlText #

Column SqlText ~ cSqlText => Default (Inferrable ToFields) Text cSqlText Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Text cSqlText #

Column SqlTimestamptz ~ cSqlTimestamptz => Default (Inferrable ToFields) UTCTime cSqlTimestamptz Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields UTCTime cSqlTimestamptz #

Column SqlText ~ cSqlText => Default (Inferrable ToFields) Text cSqlText Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Text cSqlText #

Column SqlTimestamptz ~ cSqlTimestamptz => Default (Inferrable ToFields) ZonedTime cSqlTimestamptz Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields ZonedTime cSqlTimestamptz #

Column SqlTime ~ cSqlTime => Default (Inferrable ToFields) TimeOfDay cSqlTime Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields TimeOfDay cSqlTime #

Column SqlDate ~ cSqlDate => Default (Inferrable ToFields) Day cSqlDate Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields Day cSqlDate #

Column SqlUuid ~ cSqlUuid => Default (Inferrable ToFields) UUID cSqlUuid Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields UUID cSqlUuid #

(Default (Inferrable ToFields) a b, Default Nullspec a b, MaybeFields b ~ maybeFields_b) => Default (Inferrable ToFields) (Maybe a) maybeFields_b Source # 
Instance details

Defined in Opaleye.Internal.MaybeFields

Methods

def :: Inferrable ToFields (Maybe a) maybeFields_b #

Column SqlCitext ~ cSqlCitext => Default (Inferrable ToFields) (CI Text) cSqlCitext Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (CI Text) cSqlCitext #

Column SqlCitext ~ cSqlCitext => Default (Inferrable ToFields) (CI Text) cSqlCitext Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (CI Text) cSqlCitext #

Column (SqlRange SqlInt4) ~ cRangeInt4 => Default (Inferrable ToFields) (PGRange Int) cRangeInt4 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange Int) cRangeInt4 #

Column (SqlRange SqlInt8) ~ cRangeInt8 => Default (Inferrable ToFields) (PGRange Int64) cRangeInt8 Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange Int64) cRangeInt8 #

Column (SqlRange SqlNumeric) ~ cRangeScientific => Default (Inferrable ToFields) (PGRange Scientific) cRangeScientific Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange Scientific) cRangeScientific #

Column (SqlRange SqlTimestamptz) ~ cRangeTimestamptz => Default (Inferrable ToFields) (PGRange UTCTime) cRangeTimestamptz Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange UTCTime) cRangeTimestamptz #

Column (SqlRange SqlTimestamp) ~ cRangeTimestamp => Default (Inferrable ToFields) (PGRange LocalTime) cRangeTimestamp Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange LocalTime) cRangeTimestamp #

Column (SqlRange SqlDate) ~ cRangeDate => Default (Inferrable ToFields) (PGRange Day) cRangeDate Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (PGRange Day) cRangeDate #

Column a ~ columnA => Default (Inferrable ToFields) (Column a) columnA Source # 
Instance details

Defined in Opaleye.Internal.Inferrable

Methods

def :: Inferrable ToFields (Column a) columnA #