on eba6b2e help sign in
rel8/src/Rel8/Query.hs
40 lines 867 B history raw
1{-# language DerivingStrategies #-}
2{-# language GeneralizedNewtypeDeriving #-}
3{-# language StandaloneKindSignatures #-}
5module Rel8.Query
6 ( Query( Query )
7 )
8where
10-- base
11import Data.Kind ( Type )
12import Prelude
14-- opaleye
15import qualified Opaleye.Select as Opaleye
17-- rel8
18import Rel8.Query.Set ( unionAll )
19import Rel8.Query.Values ( values )
20import Rel8.Table.Alternative
21 ( AltTable, (<|>:)
22 , AlternativeTable, emptyTable
23 )
26-- | The @Query@ monad allows you to compose a @SELECT@ query. This monad has
27-- semantics similar to the list (@[]@) monad.
28type Query :: Type -> Type
29newtype Query a = Query (Opaleye.Select a)
30 deriving newtype (Functor, Applicative, Monad)
33-- | '<|>:' = 'unionAll'.
34instance AltTable Query where
35 (<|>:) = unionAll
38-- | 'emptyTable' = 'values' @[]@.
39instance AlternativeTable Query where
40 emptyTable = values []