on b018385 help sign in
rel8/src/Rel8/Query.hs
49 lines 1.1 kB history raw
1{-# language DerivingVia #-}
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 )
25-- semigroupoids
26import Data.Functor.Apply ( Apply, WrappedApplicative(..) )
27import Data.Functor.Bind ( Bind, (>>-) )
30-- | The @Query@ monad allows you to compose a @SELECT@ query. This monad has
31-- semantics similar to the list (@[]@) monad.
32type Query :: Type -> Type
33newtype Query a = Query (Opaleye.Select a)
34 deriving newtype (Functor, Applicative, Monad)
35 deriving Apply via (WrappedApplicative Opaleye.Select)
38instance Bind Query where
39 (>>-) = (>>=)
42-- | '<|>:' = 'unionAll'.
43instance AltTable Query where
44 (<|>:) = unionAll
47-- | 'emptyTable' = 'values' @[]@.
48instance AlternativeTable Query where
49 emptyTable = values []