HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Moduleopaleye-0.10.8.0Haskell2010

Opaleye.ToFields

  • 1 type
  • 4 values
  • Packageopaleye-0.10.8.0
  • Exports5
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceToFields.hs

Creating Fields from Haskell values

2 declarations
valuetoFields :: Default ToFields haskells fields => haskells -> fields
#

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
     -> Opaleye.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.

Creating ToFields

1 declaration

Explicit versions

1 declaration

Adaptor

1 declaration
newtypenewtype ToFields haskells fields
#

A way of turning Haskell values of type haskells into SQL fields. Use it with toFields.

Instances75Profunctor, ProductProfunctor, SumProfunctor, Functor, Applicative, Default, …