on master help sign in
Fix DBSemigroup instances for [] and NonEmpty
ca9f078Shane O'Brien
src/Rel8/Type/Semigroup.hs+4−2
@@ -12,6 +12,7 @@ module Rel8.Type.Semigroup
12where
12where
13
13
14-- base
14-- base
15+import Data.Function ( on )
15import Data.Kind ( Constraint, Type )
16import Data.Kind ( Constraint, Type )
16import Data.List.NonEmpty ( NonEmpty )
17import Data.List.NonEmpty ( NonEmpty )
17import Prelude ()
18import Prelude ()
@@ -31,6 +32,7 @@ import {-# SOURCE #-} Rel8.Expr ( Expr )
31import Rel8.Expr.Opaleye ( zipPrimExprsWith )
32import Rel8.Expr.Opaleye ( zipPrimExprsWith )
32import Rel8.Schema.Null ( Sql )
33import Rel8.Schema.Null ( Sql )
33import Rel8.Type ( DBType )
34import Rel8.Type ( DBType )
35+import Rel8.Type.Array ( toPrimArray )
34
36
35-- text
37-- text
36import Data.Text ( Text )
38import Data.Text ( Text )
@@ -50,11 +52,11 @@ class DBType a => DBSemigroup a where
50
52
51
53
52instance Sql DBType a => DBSemigroup [a] where
54instance Sql DBType a => DBSemigroup [a] where
53− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
55+ (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
54
56
55
57
56instance Sql DBType a => DBSemigroup (NonEmpty a) where
58instance Sql DBType a => DBSemigroup (NonEmpty a) where
57− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
59+ (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
58
60
59
61
60instance DBSemigroup CalendarDiffTime where
62instance DBSemigroup CalendarDiffTime where