1{-# language BlockArguments #-}
2{-# language DataKinds #-}
3{-# language FlexibleContexts #-}
4{-# language FlexibleInstances #-}
5{-# language MultiParamTypeClasses #-}
6{-# language StandaloneKindSignatures #-}
7{-# language TypeFamilies #-}
8{-# language UndecidableInstances #-}
10module Rel8.Type.Semigroup
16import Data.Kind ( Constraint, Type )
17import Data.List.NonEmpty ( NonEmpty )
21import Data.ByteString ( ByteString )
22import qualified Data.ByteString.Lazy as Lazy ( ByteString )
25import Data.CaseInsensitive ( CI )
28import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
31import {-# SOURCE #-} Rel8.Expr ( Expr )
32import Rel8.Expr.Array ( sappend, sappend1 )
33import Rel8.Expr.Opaleye ( zipPrimExprsWith )
34import Rel8.Schema.Null ( Sql )
35import Rel8.Type ( DBType )
38import Data.Text ( Text )
39import qualified Data.Text.Lazy as Lazy ( Text )
42import Data.Time.LocalTime ( CalendarDiffTime )
45-- | The class of 'Rel8.DBType's that form a semigroup. This class is purely a
46-- Rel8 concept, and exists to mirror the 'Semigroup' class.
47type DBSemigroup :: Type -> Constraint
48class DBType a => DBSemigroup a where
49 -- | An associative operation.
50 (<>.) :: Expr a -> Expr a -> Expr a
54instance Sql DBType a => DBSemigroup [a] where
58instance Sql DBType a => DBSemigroup (NonEmpty a) where
62instance DBSemigroup CalendarDiffTime where
63 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:+))
66instance DBSemigroup Text where
67 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
70instance DBSemigroup Lazy.Text where
71 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
74instance DBSemigroup (CI Text) where
75 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
78instance DBSemigroup (CI Lazy.Text) where
79 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
82instance DBSemigroup ByteString where
83 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
86instance DBSemigroup Lazy.ByteString where
87 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list