composite-opaleye 0.8.2.1 → 0.8.2.2
raw patch · 5 files changed
+27/−14 lines, 5 filesdep ~lensPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: lens
API changes (from Hackage documentation)
+ Composite.Opaleye.RecToFields: class RecToFields (haskells :: [Type]) (fields :: [Type])
+ Composite.Opaleye.RecToFields: instance (Data.Profunctor.Product.Default.Class.Default Opaleye.Internal.Constant.ToFields h f, Composite.Opaleye.RecToFields.RecToFields haskells fields) => Composite.Opaleye.RecToFields.RecToFields ((s Composite.Record.:-> h) : haskells) ((s Composite.Record.:-> f) : fields)
+ Composite.Opaleye.RecToFields: instance Composite.Opaleye.RecToFields.RecToFields '[] '[]
+ Composite.Opaleye.RecToFields: recToFields :: RecToFields haskells fields => Rec Identity haskells -> Rec Identity fields
- Composite.Opaleye.ProductProfunctors: type PRecCo p rs :: [*];
+ Composite.Opaleye.ProductProfunctors: type PRecCo p rs :: [Type];
- Composite.Opaleye.ProductProfunctors: type PRecContra p rs :: [*];
+ Composite.Opaleye.ProductProfunctors: type PRecContra p rs :: [Type];
- Composite.Opaleye.Update: class RecordToUpdate (rs :: [*]) (ss :: [*])
+ Composite.Opaleye.Update: class RecordToUpdate (rs :: [Type]) (ss :: [Type])
Files
- composite-opaleye.cabal +4/−7
- src/Composite/Opaleye.hs +2/−0
- src/Composite/Opaleye/ProductProfunctors.hs +3/−5
- src/Composite/Opaleye/RecToFields.hs +16/−0
- src/Composite/Opaleye/Update.hs +2/−2
composite-opaleye.cabal view
@@ -1,11 +1,7 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.7.------ see: https://github.com/sol/hpack- name: composite-opaleye-version: 0.8.2.1+version: 0.8.2.2 synopsis: Opaleye SQL for Vinyl records description: Integration between Vinyl records and Opaleye SQL, allowing records to be stored, retrieved, and queried from PostgreSQL. category: Records@@ -21,6 +17,7 @@ Composite.Opaleye Composite.Opaleye.ProductProfunctors Composite.Opaleye.RecordTable+ Composite.Opaleye.RecToFields Composite.Opaleye.TH Composite.Opaleye.Update Composite.Opaleye.Util@@ -48,7 +45,7 @@ base >=4.12 && <5 , bytestring >=0.10.8.1 && <0.12 , composite-base ==0.8.*- , lens >=4.15.4 && <5.2+ , lens >=4.15.4 && <5.3 , opaleye >=0.9.0 && <0.10 , postgresql-simple >=0.5.3.0 && <0.7 , product-profunctors >=0.8.0.3 && <0.12@@ -90,7 +87,7 @@ , composite-base ==0.8.* , composite-opaleye , hspec- , lens >=4.15.4 && <5.2+ , lens >=4.15.4 && <5.3 , opaleye >=0.9.0 && <0.10 , postgresql-simple >=0.5.3.0 && <0.7 , product-profunctors >=0.8.0.3 && <0.12
src/Composite/Opaleye.hs view
@@ -1,9 +1,11 @@ module Composite.Opaleye ( module Composite.Opaleye.ProductProfunctors , module Composite.Opaleye.RecordTable+ , module Composite.Opaleye.RecToFields , module Composite.Opaleye.Update ) where import Composite.Opaleye.ProductProfunctors import Composite.Opaleye.RecordTable+import Composite.Opaleye.RecToFields import Composite.Opaleye.Update
src/Composite/Opaleye/ProductProfunctors.hs view
@@ -3,6 +3,7 @@ import Composite.Record ((:->)(Val), Rec((:&), RNil)) import Data.Functor.Identity (Identity(Identity))+import Data.Kind (Type) import Data.Profunctor (dimap) import Data.Profunctor.Product (ProductProfunctor, (***!)) import qualified Data.Profunctor.Product as PP@@ -14,9 +15,9 @@ -- This is similar to the @pN@ functions on tuples provided by the @product-profunctors@ library. class ProductProfunctor p => PRec p rs where -- |Record fields @rs@ with the profunctor removed yielding the contravariant parameter. E.g. @PRecContra p '[p a b] ~ '[a]@- type PRecContra p rs :: [*]+ type PRecContra p rs :: [Type] -- |Record fields @rs@ with the profunctor removed yielding the covariant parameter. E.g. @PRecContra p '[p a b] ~ '[a]@- type PRecCo p rs :: [*]+ type PRecCo p rs :: [Type] -- |Traverse the record, transposing the profunctors @p@ within to the outside like 'traverse' does for Applicative effects. --@@ -52,6 +53,3 @@ step = def recur :: p (Rec Identity rsContra) (Rec Identity rsCo) recur = def---
+ src/Composite/Opaleye/RecToFields.hs view
@@ -0,0 +1,16 @@+module Composite.Opaleye.RecToFields where++import Composite.Record (pattern (:*:), Rec((:&), RNil), (:->)(Val))+import Data.Functor.Identity (Identity(Identity))+import Data.Kind (Type)+import Data.Profunctor.Product.Default (Default)+import Opaleye (ToFields, toFields)++class RecToFields (haskells :: [Type]) (fields :: [Type]) where+ recToFields :: Rec Identity haskells -> Rec Identity fields++instance RecToFields '[] '[] where+ recToFields RNil = RNil++instance (Default ToFields h f, RecToFields haskells fields) => RecToFields (s :-> h ': haskells) (s :-> f ': fields) where+ recToFields hs' = let Identity (Val h) :& hs = hs' in toFields h :*: recToFields hs
src/Composite/Opaleye/Update.hs view
@@ -5,10 +5,11 @@ import Composite.Record ((:->)(Val), Rec((:&), RNil), Record) import Data.Functor.Identity (Identity(Identity))+import Data.Kind (Type) -- |Typeclass which allows transformation of a record from its select form to neutral update form, which boils down to wrapping fields that have defaults -- with 'Just'.-class RecordToUpdate (rs :: [*]) (ss :: [*]) where+class RecordToUpdate (rs :: [Type]) (ss :: [Type]) where -- |Transform a @'Record' rs@ obtained from the database to a @'Record' ss@ representing an updated version of the row. -- -- Opaleye's @runUpdate@ family of functions all take an update function of the type @columnsR -> columnsW@, which this function implements generically@@ -31,4 +32,3 @@ instance RecordToUpdate rs ss => RecordToUpdate (s :-> a ': rs) (s :-> Maybe a ': ss) where recordToUpdate (Identity (Val a) :& rs) = Identity (Val (Just a)) :& recordToUpdate rs {-# INLINE recordToUpdate #-}-