Skip to content

Commit

Permalink
Add Monoid instance for Query (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-circuithub authored Oct 17, 2022
1 parent 5eb5689 commit d2f05bd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Rel8/Query.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{-# language FlexibleContexts #-}
{-# language StandaloneKindSignatures #-}
{-# language UndecidableInstances #-}

module Rel8.Query
( Query( Query )
Expand All @@ -20,10 +22,11 @@ import qualified Opaleye.Internal.QueryArr as Opaleye
import qualified Opaleye.Internal.Tag as Opaleye

-- rel8
import Rel8.Expr ( Expr )
import Rel8.Query.Set ( unionAll )
import Rel8.Query.Opaleye ( fromOpaleye )
import Rel8.Query.Values ( values )
import Rel8.Table ( fromColumns, toColumns )
import Rel8.Table ( Table, fromColumns, toColumns )
import Rel8.Table.Alternative
( AltTable, (<|>:)
, AlternativeTable, emptyTable
Expand Down Expand Up @@ -208,3 +211,13 @@ instance AltTable Query where
-- | 'emptyTable' = 'values' @[]@.
instance AlternativeTable Query where
emptyTable = values []


-- | '<>' = 'unionAll'.
instance Table Expr a => Semigroup (Query a) where
(<>) = (<|>:)


-- | 'mempty' = @'values' []@.
instance Table Expr a => Monoid (Query a) where
mempty = emptyTable

0 comments on commit d2f05bd

Please sign in to comment.