on master help sign in
Semigroupoids instances for Query 😈
98fd6f4Shane O'Brien
src/Rel8/Query.hs+10
@@ -1,4 +1,5 @@
1{-# language DerivingStrategies #-}
1{-# language DerivingStrategies #-}
2+{-# language DerivingVia #-}
2{-# language GeneralizedNewtypeDeriving #-}
3{-# language GeneralizedNewtypeDeriving #-}
3{-# language StandaloneKindSignatures #-}
4{-# language StandaloneKindSignatures #-}
4
5
@@ -22,12 +23,21 @@ import Rel8.Table.Alternative
22 , AlternativeTable, emptyTable
23 , AlternativeTable, emptyTable
23 )
24 )
24
25
26+-- semigroupoids
27+import Data.Functor.Apply ( Apply, WrappedApplicative(..) )
28+import Data.Functor.Bind ( Bind, (>>-) )
29+
25
30
26-- | The @Query@ monad allows you to compose a @SELECT@ query. This monad has
31-- | The @Query@ monad allows you to compose a @SELECT@ query. This monad has
27-- semantics similar to the list (@[]@) monad.
32-- semantics similar to the list (@[]@) monad.
28type Query :: Type -> Type
33type Query :: Type -> Type
29newtype Query a = Query (Opaleye.Select a)
34newtype Query a = Query (Opaleye.Select a)
30 deriving newtype (Functor, Applicative, Monad)
35 deriving newtype (Functor, Applicative, Monad)
36+ deriving Apply via (WrappedApplicative Opaleye.Select)
37+
38+
39+instance Bind Query where
40+ (>>-) = (>>=)
31
41
32
42
33-- | '<|>:' = 'unionAll'.
43-- | '<|>:' = 'unionAll'.