on master help sign in
Actually fix DBSemigroup instance for lists
89ec060Shane O'Brien
src/Rel8/Type/Semigroup.hs+7−4
@@ -1,3 +1,4 @@
1+{-# language BlockArguments #-}
1{-# language DataKinds #-}
2{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language FlexibleContexts #-}
3{-# language FlexibleInstances #-}
4{-# language FlexibleInstances #-}
@@ -15,7 +16,7 @@ where
15import Data.Function ( on )
16import Data.Function ( on )
16import Data.Kind ( Constraint, Type )
17import Data.Kind ( Constraint, Type )
17import Data.List.NonEmpty ( NonEmpty )
18import Data.List.NonEmpty ( NonEmpty )
18−import Prelude ()
19+import Prelude
19
20
20-- bytestring
21-- bytestring
21import Data.ByteString ( ByteString )
22import Data.ByteString ( ByteString )
@@ -32,7 +33,7 @@ import {-# SOURCE #-} Rel8.Expr ( Expr )
32import Rel8.Expr.Opaleye ( zipPrimExprsWith )
33import Rel8.Expr.Opaleye ( zipPrimExprsWith )
33import Rel8.Schema.Null ( Sql )
34import Rel8.Schema.Null ( Sql )
34import Rel8.Type ( DBType )
35import Rel8.Type ( DBType )
35−import Rel8.Type.Array ( toPrimArray )
36+import Rel8.Type.Array ( fromPrimArray, toPrimArray )
36
37
37-- text
38-- text
38import Data.Text ( Text )
39import Data.Text ( Text )
@@ -52,11 +53,13 @@ class DBType a => DBSemigroup a where
52
53
53
54
54instance Sql DBType a => DBSemigroup [a] where
55instance Sql DBType a => DBSemigroup [a] where
56+ (<>.) = zipPrimExprsWith do
55− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
57+ (fromPrimArray .) . Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray
56
58
57
59
58instance Sql DBType a => DBSemigroup (NonEmpty a) where
60instance Sql DBType a => DBSemigroup (NonEmpty a) where
61+ (<>.) = zipPrimExprsWith do
59− (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray)
62+ (fromPrimArray .) . Opaleye.BinExpr (Opaleye.:||) `on` toPrimArray
60
63
61
64
62instance DBSemigroup CalendarDiffTime where
65instance DBSemigroup CalendarDiffTime where