on dev help sign in
andThen
commitb9103f40cc9e5b29cf20ec06421181cf4b1a629a authorEitan Chatav <eitan.chatav@gmail.com> dateMon 9 Apr 2018, 09:17 (9 years ago) parent7f55fa5
1 file changed+10−4
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+10−4
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+10−4
@@ -217,6 +217,7 @@ class IndexedMonadTransPQ pq where
217217 :: Monad m
218218 => pq schema0 schema1 m (pq schema1 schema2 m y)
219219 -> pq schema0 schema2 m y
220+ pqJoin pq = pq & pqBind id
220221
221222 -- | indexed analog of `=<<`
222223 pqBind
@@ -231,6 +232,15 @@ class IndexedMonadTransPQ pq where
231232 => pq schema1 schema2 m y
232233 -> pq schema0 schema1 m x
233234 -> pq schema0 schema2 m y
235+ pqThen pq2 pq1 = pq1 & pqBind (\ _ -> pq2)
236+
237+ -- | indexed analog of `<=<`
238+ pqAndThen
239+ :: Monad m
240+ => (y -> pq schema1 schema2 m z)
241+ -> (x -> pq schema0 schema1 m y)
242+ -> x -> pq schema0 schema2 m z
243+ pqAndThen g f x = pqBind g (f x)
234244
235245 -- | Safely embed a computation in a larger schema.
236246 pqEmbed
@@ -253,14 +263,10 @@ instance IndexedMonadTransPQ PQ where
253263 K x' <- x (K (unK conn))
254264 return $ K (f' x')
255265
256− pqJoin pq = pq & pqBind id
257−
258266 pqBind f (PQ x) = PQ $ \ conn -> do
259267 K x' <- x conn
260268 unPQ (f x') (K (unK conn))
261269
262− pqThen pq2 pq1 = pq1 & pqBind (\ _ -> pq2)
263−
264270 pqEmbed (PQ pq) = PQ $ \ (K conn) -> do
265271 K x <- pq (K conn)
266272 return $ K x