on master help sign in
Fix DBSemigroup instances for [] and NonEmpty
commitca9f078c569905d87e324017b67565cb067a93dc authorShane O'Brien <shane.obrien@circuithub.com> dateSat 12 Jun 2021, 20:02 (5 years ago) parentdef349e
1 file changed+4−2
src/Rel8/Type/Semigroup.hs+4−2
src/Rel8/Type/Semigroup.hs+4−2
@@ -12,6 +12,7 @@ module Rel8.Type.Semigroup
1212where
1313
1414-- base
15+import Data.Function ( on )
1516import Data.Kind ( Constraint, Type )
1617import Data.List.NonEmpty ( NonEmpty )
1718import Prelude ()
@@ -31,6 +32,7 @@ import {-# SOURCE #-} Rel8.Expr ( Expr )
3132import Rel8.Expr.Opaleye ( zipPrimExprsWith )
3233import Rel8.Schema.Null ( Sql )
3334import Rel8.Type ( DBType )
35+import Rel8.Type.Array ( toPrimArray )
3436
3537-- text
3638import Data.Text ( Text )
@@ -50,11 +52,11 @@ class DBType a => DBSemigroup a where
5052
5153
5254instance Sql DBType a => DBSemigroup [a] where
53− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
55+ (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
5456
5557
5658instance Sql DBType a => DBSemigroup (NonEmpty a) where
57− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
59+ (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
5860
5961
6062instance DBSemigroup CalendarDiffTime where