1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language FlexibleInstances #-}
4{-# language MultiParamTypeClasses #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
7{-# language UndecidableInstances #-}
9module Rel8.Type.Semigroup
15import Data.Kind ( Constraint, Type )
16import Data.List.NonEmpty ( NonEmpty )
20import Data.ByteString ( ByteString )
21import qualified Data.ByteString.Lazy as Lazy ( ByteString )
24import Data.CaseInsensitive ( CI )
27import qualified Opaleye.Internal.HaskellDB.PrimQuery as Opaleye
30import {-# SOURCE #-} Rel8.Expr ( Expr )
31import Rel8.Expr.Opaleye ( zipPrimExprsWith )
32import Rel8.Schema.Null ( Sql )
33import Rel8.Type ( DBType )
36import Data.Text ( Text )
37import qualified Data.Text.Lazy as Lazy ( Text )
40import Data.Time.LocalTime ( CalendarDiffTime )
43-- | The class of 'Rel8.DBType's that form a semigroup. This class is purely a
44-- Rel8 concept, and exists to mirror the 'Semigroup' class.
45type DBSemigroup :: Type -> Constraint
46class DBType a => DBSemigroup a where
47 -- | An associative operation.
48 (<>.) :: Expr a -> Expr a -> Expr a
52instance Sql DBType a => DBSemigroup [a] where
53 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
56instance Sql DBType a => DBSemigroup (NonEmpty a) where
57 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
60instance DBSemigroup CalendarDiffTime where
61 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:+))
64instance DBSemigroup Text where
65 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
68instance DBSemigroup Lazy.Text where
69 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
72instance DBSemigroup (CI Text) where
73 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
76instance DBSemigroup (CI Lazy.Text) where
77 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
80instance DBSemigroup ByteString where
81 (<>.) = zipPrimExprsWith (Opaleye.BinExpr (Opaleye.:||))
84instance DBSemigroup Lazy.ByteString where
85 (<>.) = 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